Hi! Basically, I'm making a PHP file that lists things from a file, so if the file contained; '@-Line 1-@@-Line 2-@' it would produce <li><a href="#">Line 1</a></li><li><a href="#">Line 2</a></li>, but I want it so it changes the coding for 1 of every 2 lines. So I've came up with this code:
$myFile = "list.txt";
$fh = fopen($myFile, 'r');
$theData = fread($fh, 100);
fclose($fh);
$oldtxt = array("@-", "-@");
$newtxt = array('<li><a href="#">','</a></li>');
$newData = str_replace($oldtxt, $newtxt, $theData);
$array = explode("</li>", trim($newData));
$lineno = count($array);
$linenofinal = $lineno - 1;
for($i=1;$i<$linenofinal;$i++){
if(($i % 2)=='0'){
}
}
The bit that I'm stuck on is inside the if statement. How could I get it to replace for example <li> in line $i with <li class="1in2">
Thanks in advance,
Daviga404 =D