my json decode script throwing error i.e. Error : DATA FETCH
My code:
<?php
$api_url = '{"msg":"SUCCESS","msg_text":"DATA FETCH","data":[{"sn":1,"mob_no":"9602858989","date":"06-May-2015","time":"12:02:33 PM"},{"sn":2,"mob_no":"7795055128","date":"06-May-2015","time":"12:29:44 PM"}]}';
$output = file_get_contents($api_url);
if($output=="")
{
echo "No output received";
}
else
{
$arr_output = json_decode($output, true);
if(isset($arr_output['msg']))
{
$msg = $arr_output['msg'];
$msg_text = $arr_output['msg_text'];
if($msg == "success")
{
if(isset($arr_output['data']))
{
$arr_data = $arr_output['data'];
// above array will contain your data
print_r($arr_data);
}
else
{
echo "Json data not set !!";
}
}
else
{
echo "Error : ".$msg_text;
}
}
else
{
echo "Output not set !!";
}
}
?>