<?php
$string = '{"71":"message1","72":"message2" }';
$keys = array_keys(json_decode($string, TRUE));
print_r($keys);
output:
Array ( [0] => 71 [1] => 72 )
json
The json string being decoded.
This function only works with UTF-8 encoded strings.
Note:
PHP implements a superset of JSON as specified in the original » RFC 7159.
assoc
When TRUE, returned objects will be converted into associative arrays.
depth
User specified recursion depth
Return Values
Returns the value encoded in json in appropriate PHP type. Values true, false and null are returned as TRUE, FALSE and NULL respectively. NULL is returned if the json cannot be decoded or if the encoded data is deeper than the recursion limit.
Reference: http://php.net/manual/en/function.json-decode.php