Can't seem to work out how to access data within an array that has other arrays within it.
My array looks like:
Array
(
[0] => Array
(
[_id] => 28
[serv_image] =>
[serv_name] => My Service
[slug] => my-service
[is_featured] =>
[_blocks] => Array
(
[0] => Array
(
[anchor_heading] => Mats Heading
[_block_type] => anchorHeading
[_block_id] => pe8t69
[_block_index] => 0
)
[1] => Array
(
[anchor_heading] => Another anchored heading
[_block_type] => anchorHeading
[_block_id] => pea49u
[_block_index] => 1
)
)
[_page] => *
[_pageID] => 1
[_sortvalue] => 1003
)
)
So far I've tried this without success:
foreach($services as $service) {
print_r($service['_blocks']['anchor_heading']);
}
This results in undefined index on anchor_heading
.
UPDATE
I will have an unknown amount of these that I need to group together into a variable. How can I ensure I'm grabbing them all, no matter how many other times it's been entered?