JSON string $json_string = json_encode(['my_key' => 'my value', 'other_key' => 'other value']); echo $json_string; # JSON string -> PHP object $json_string = '{"my_key":"my value","other_key":"other value"}'; $my_array = json_decode($json_string); print_r($my_array) // Dump/read from file file_put_contents('test.json', json_encode([2, 4, 6])); $my_array = json_decode(file_get_contents('test.json')); print_r($my_array);