how to create array of object json_encode in php code example Example: php return json header('Content-type: application/json'); echo json_encode($array);