I need some help on this topic, I have treated it as an array but it doesn't go through I need your help.
$url = file_get_contents("https://servidor.com/json");
$prueba = json_decode($url,true);
$stdClass = json_decode(json_encode($url,true));
print_r ($prueba);
print_r ($stdClass);
FIRST PAINT
Array ( [consultarResponse] => Array ( [return] => Array ( [coResultado] => 0000 [datosPersona] => Array ( [apPrimer] => MERCEDES [apSegundo] => REYES [direccion] => AV.CESAR VALLEJO 1126 [estadoCivil] => SOLTERO [foto] => /9j/4AAQSkZJRgABAgA [prenombres] => HILMAR ALEXIS [restriccion] => NINGUNA [ubigeo] => LA LIBERTAD/TRUJILLO/TRUJILLO ) [deResultado] => Consulta realizada correctamente ) ) )
SECOND PRINT
{"consultarResponse":{"return":{"coResultado":"0000","datosPersona":{"apPrimer":"MERCEDES","apSegundo":"REYES","direccion":"AV.CESAR VALLEJO 1126","estadoCivil":"SOLTERO","foto":"/9j/4AAQSkZJRgABAgA","prenombres":"HILMAR ALEXIS","restriccion":"NINGUNA","ubigeo":"LA LIBERTAD/TRUJILLO/TRUJILLO"},"deResultado":"Consulta realizada correctamente"}}}
Based on the following comments:
As you said, it is an array with arrays inside and to get to the point where the data you need is found, you have to " access " to the " depth " where it is found.
Another way to look at it would be:
Solution:
You could achieve it in the following way: