Ask about general coding issues or problems here.
Moderators: macek, egami, gesf
by Albertogomes » Tue Nov 06, 2012 8:23 am
for($j=0;$j<$i;$j++){
if($produto == $produtos[$j]){
echo $produto;
break;
}
else echo "error"; // errorerrorerroerror$produto if the last exists and error when the others are differnt
}
im trying to get a variable if exists in an array and get an error message if that variable doesn´t exists in the array. how can i do that? Thanks
-
Albertogomes
- New php-forum User

-
- Posts: 2
- Joined: Tue Oct 30, 2012 8:28 am
by simplypixie » 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.
-

simplypixie
- php-forum Active User

-
- Posts: 289
- Joined: Sun Dec 11, 2011 12:51 am
- Location: Shrewsbury, Shropshire
-
Return to PHP coding => General
Who is online
Users browsing this forum: No registered users and 2 guests