2
I’m trying to create a kind of inventory in php. basically a program that by placing a certain number on the screen, it takes you to the inventory, where you can pick up and remove items.
I’m trying to make the program show all the items that are marked with the number 3 (number that identifies the item is in the inventory), but I don’t know how to do the following algorithm in php:
$itens=array('ameixa' => 2, 'abacate'=>3, 'mamão' =>1, 'maçã' =>3);
echo'<table style="align:center;" border="1">';
for($i=0;$i<=$itens.lengh; $i++)
{
if($itens[$i] == 3)
{
echo'<tr>
<td>'.$itens[$i].'</td></tr>';
}
}
The comparison signal is == and not just one, which would set a value to a variable.
– Kevin Kouketsu
Okay, but the command
"variável".lengh
works in php?– riki481
Use the
foreach
to traverse array in PHP.– Woss
and how do I pull not only the number, but the name of the array as well?
– riki481
Studying as the
foreach
works :D– Woss