I can’t understand where the error is, the code is correct, but some elements of json are simply not readable.
There is data I try to structure them into one array taking only the necessary elements.
$obj = json_decode($data,true); $mas=array(); for ($i = 0; $i <count($obj['included']); $i++) { if ($obj['included'][$i]['type']='vacancyDetailInfo'){ $id=$obj['included'][$i]['id']; $mas[$id]['duties']= $obj['included'][$i]['attributes']['duties']; $mas[$id]['requirements']= $obj['included'][$i]['attributes']['requirements']; $mas[$id]['conditions']= $obj['included'][$i]['attributes']['conditions']; } if ($obj['included'][$i]['type']='vacancyMainInfo'){ $id=$obj['included'][$i]['id']; $mas[$id]['profession']= $obj['included'][$i]['attributes']['profession']; $mas[$id]['minSalary']= $obj['included'][$i]['attributes']['minSalary']; $mas[$id]['maxSalary']= $obj['included'][$i]['attributes']['maxSalary']; } } print_r ($mas);
I end up with an array of this type
Array ( [31259521] => Array ( [duties] => [requirements] => [conditions] => [profession] => Менеджер по развитию продаж на строительные объекты [minSalary] => 0 [maxSalary] => 0 ) [31780640] => Array ( [duties] => [requirements] => [conditions] => [profession] => Энергетик, специалист по охране труда и промышленной безопасности [minSalary] => 40000 [maxSalary] => 0 )
why the duties, requirements, conditions are not read, more precisely in the array is not added? and if you turn like this
echo $obj['included'][0]['attributes']['duties'];
Is its contents normally displayed?