how can i get good output of this script: Source JSON: https://ufile.io/sn0hu
I need get values into array and in the next step take into variables. Values is result->data->tab->unified_content->item (type->text if header = title and if text = description)
Script:
function getContent($data) {
$tabs = $data->result->data->tab;
foreach($tabs as $tab){
$content = [];
if(isset($tab->unified_content->item)) {
foreach($tab->unified_content->item as $item) {
if($item->type->name == 'header') {
$arr = [];
$arr['title'] = $item->text;
} else {
$arr['description'] = $item->text;
$content[] = $arr;
}
}
return $content;
}
}
}
$test = getContent($data);
foreach ($test as $lol) {
var_dump($lol);
}
Now is output this: array(1) { ["description"]=> string(0) "" }