0

please help me with this json_decode array. this is my first time using this function. i want to echo the array but its keep showing error. here is my code:

<?php
ini_set("allow_url_fopen", 1);
$json = file_get_contents('http://sippadu.dpmptsp.sidoarjokab.go.id/bppt/int/m_tracking_qrcode.jsp?idtrack=08112017N1N083150');
$obj = json_decode($json);

echo "Izin:".$obj->izin."<br>";
echo "Nama:". $obj->nama;

?>

this is output form json_decode im using print_r:

stdClass Object ( [records] => Array ( [0] => stdClass Object ( [izin] => (N08) Surat Izin Usaha Perdagangan (SIUP) [nama] => CV TIRTO MULYO [status] => Izin Anda sudah selesai. ) ) ) 

the error:

Notice: Undefined property: stdClass::$nama in /storage/ssd4/441/3008441/public_html/asd.php on line 7

please help, i just follow this instruction in other stackoverflow post. but my result false, thanks

principiorum
  • 528
  • 7
  • 21

1 Answers1

0

As you can see, the print_r produced an array of objects. So you need to access that array first before going ahead with nama and izin

It should be $obj['records'][0]->izin and $obj['records'][0]->nama

cyberrspiritt
  • 908
  • 8
  • 26