Page 1 of 1

Re: new to PHP cicle and array problem

Posted: Tue Nov 06, 2012 11:46 pm
by simplypixie
Where is are your variables $i and $producto being defined (could do with seing them to make sure your loop will work in the first instance)?

Also, you don't break within your for loop so remove that.

Re: new to PHP cicle and array problem

Posted: Wed Nov 07, 2012 2:17 am
by MeroD
<?php
foreach ($produtos as $plist) {
  if ( in_array($plist, $produto) ) {
    echo $plist . " Found!<br />";
  }
  else {
    echo "Product not found!<br />";
  }
}
?>

http://www.w3schools.com/php/func_array_in_array.asp
http://www.php.net/manual/en/function.in-array.php