Friday, August 12, 2011

Using php get data from json file (url)

<?php

$siva = file_get_contents('http://jacksiva.blogspot.com/json/exm.json');

$array = json_decode($siva, true);

echo $array['sample'][0]['emp_fname'];

?>

output:
karan

example json file:
exm.json:

{"sample":[{"0":"61","id":"61","1":"karan","emp_fname":"karan","2":"kar","emp_lname":"kar","3":"3333","emp_id":"3333","4":"karan@mail.com","emp_email":"karan@mail.com","5":"6","job_id":"6","6":"0105","manage_id":"0105","7":"2011-03-18 12:15:50","mod_date":"2011-03-18 12:15:50"},{"0":"60","id":"60","1":"jijujames","emp_fname":"jijujames","2":"jiju","emp_lname":"jiju","3":"2222","emp_id":"2222","4":"jijujames@mail.com","emp_email":"jijujames@mail.com","5":"6","job_id":"6","6":"0105","manage_id":"0105","7":"2011-03-18 12:13:24","mod_date":"2011-03-18 12:13:24"},{"0":"59","id":"59","1":"Syed Ibrahim","emp_fname":"Syed Ibrahim","2":"Syed ","emp_lname":"Syed ","3":"0000","emp_id":"0000","4":"","emp_email":"","5":"4","job_id":"4","6":"0071","manage_id":"0071","7":"2011-01-27 17:10:27","mod_date":"2011-01-27 17:10:27"},{"0":"58","id":"58","1":"Vetriselvan","emp_fname":"Vetriselvan","2":"K","emp_lname":"K","3":"4053","emp_id":"4053","4":"","emp_email":"","5":"4","job_id":"4","6":"0071","manage_id":"0071","7":"2011-01-27 16:48:53","mod_date":"2011-01-27 16:48:53"},{"0":"55","id":"55","1":"Deepalakshmi","emp_fname":"Deepalakshmi","2":"S.","emp_lname":"S.","3":"4020","emp_id":"4020","4":"","emp_email":"","5":"4","job_id":"4","6":"0207","manage_id":"0207","7":"2011-01-27 11:32:02","mod_date":"2011-01-27 11:32:02"}]}




No comments:

Post a Comment