Create JSON data in PHP

json_encode

Code:

$data = array ('id'=>1, 'firstname'=>'george', 
    'lastname'=>'karpouzas',
       'emails'=>array('abcd@gmail.com','abcd@yahoo.com'));
 
echo json_encode($data);

Output:
{“id”:1,”firstname”:”george”,”lastname”:”karpouzas”,”emails”:[“abcd@gmail.com”,”abcd@yahoo.com”]}

Categories: PHP Tags: , , ,
%d bloggers like this: