I have these data array stored in variable $ids
array(3) {
[0]=>
array(1) {
["id"]=>
string(3) "472"
}
[1]=>
array(1) {
["id"]=>
string(3) "475"
}
[26]=>
array(1) {
["id"]=>
string(3) "498"
}
}
How can I get value of each id? I tried with for
loop but it's not working.
for ($i=0; $i < count($ids); $i++){
echo "ID is " . $ids['id'][$i];
}
Try the foreach
loop instead:
foreach($ids as $id)
{
echo "ID is " . $id['id'];
}
Because your keys are are not like 1,2,3....
, the for
loop won't work, but foreach
will.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments