new to PHP cicle and array problem

Ask about general coding issues or problems here.

Moderators: egami, macek, gesf

Post Reply
User avatar
simplypixie
php-forum Active User
php-forum Active User
Posts: 300
Joined: Sun Dec 11, 2011 12:51 am
Location: Shrewsbury, Shropshire
Contact:

Tue Nov 06, 2012 11:46 pm

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.

MeroD
New php-forum User
New php-forum User
Posts: 53
Joined: Wed Oct 10, 2012 12:14 am

Wed Nov 07, 2012 2:17 am

<?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

Post Reply