I have a multidimensional array within these arrays contains array objects. How can I iterate over a specific array object for example in value2 > [1] > iterate all Account_ID's in members array?
Array(
[value1] => text
[value2] => Array (
[0] => stdClass Object (
[Project_Title] => Project B Test
[members] => Array(
[0] => stdClass Object ( [Account_ID] => 5 )
)
)
[1] => stdClass Object (
[Project_Title] => Project A Test
[members] => Array(
[0] => stdClass Object ([Account_ID] => 9 )
[1] => stdClass Object ([Account_ID] => 11)
[2] => stdClass Object ([Account_ID] => 13)
[3] => stdClass Object ([Account_ID] => 14)
[4] => stdClass Object ([Account_ID] => 15)
[5] => stdClass Object ([Account_ID] => 16)
[6] => stdClass Object ([Account_ID] => 17)
[7] => stdClass Object ([Account_ID] => 18)
[8] => stdClass Object ([Account_ID] => 19)
)
)
)
)
Basically you can do this by doing exactly what you are saying. Something like this will work!
foreach( $array['value2'][1]->members as $key => $memberObject ) {
echo $memberObject->Account_ID ."<br />";
}
This could be one basic solution:
foreach ($array['value2'] as $object) {
foreach ($object->members as $obj) {
echo $obj->Account_ID;
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.