PHP for loop, need it to skip if it finds a certain number but not stop ?

  • Thread starter Thread starter hippiejane
  • Start date Start date
H

hippiejane

Guest
Say you have an array that is a bunch of numbers ($test), that has been taken fron a database as an array.
And you want to print the list of numbers except for one, say the number '7'.
How would you do this ?

The number you dont want printed would be a variable:
$except = '7';

I have tried but I can only get the while loop to stop when it comes to that variable. I need it to skip it and keep going.

My loop looks like so:

<?
for($i=0; $i< count($test); $i++) {
echo '$test[$i]';
}
?>

Any help would be great. My PHP knowledge isnt fabulous.
 
Back
Top