- var_dump: documentation ( source)
- json_encode: documentation ( source)
<?php
$arr = array(
"@context" => "http://schema.org",
"@type" => "BreadcrumbList",
"itemListElement" => array([
"@type" => "ListItem",
"position" => 1,
"item" =>[
"@id" => "www.example.com/",
"name" => "Home"
]
//I need $lab[] to show here
])
);
$i = 1;
foreach ($pages as $page) {
$i++;
$arr['itemListElement'][] = [
'@type' => 'ListItem',
'position' => $i,
'item' => [
"@id" => $page->getUri(),
"name" =>$page->getLabel()
]];
}
var_dump($arr,$lab);
json_encode($arr);