Hello, I have $arr as an array with some values, now I want in this foreach, when $res->year() == a value of the $arr not showing, that's my foreach: $arr $i = 0; foreach ($results as $res) { echo '<li>'; echo '<a href="'. imdblink($res->imdbid(), $res->year(), $res->title()).'" title="'.$res->title().' '.$res->year().'">'.fewchars("".$res->title()." (".$res->year().")", 35).'</a>'; //echo "<li> <a href='suggest.php?mid=".$res->imdbid()."'>".$res->title()." (".$res->year().")</li>"; echo '</li>'; $i++; if ($i > 11) break; } PHP: I'm far away from a solution
how many items are in your array? you are breaking out after 11 times. if you want to show all values in your array then you need to remove this line if ($i > 11) break; PHP:
Just make a simple if: $arr $i = 0; foreach ($results as $res) { if($res->year() != a) { echo '<li>'; echo '<a href="'. imdblink($res->imdbid(), $res->year(), $res->title()).'" title="'.$res->title().' '.$res->year().'">'.fewchars("".$res->title()." (".$res->year().")", 35).'</a>'; //echo "<li> <a href='suggest.php?mid=".$res->imdbid()."'>".$res->title()." (".$res->year().")</li>"; echo '</li>'; $i++; if ($i > 11) break; } } PHP:
No that's not working, I tried that as well, but $arr is an array with different values and it should be like each value not the same