php: different between array( ) and { } -
what's different between
array ( [user_id] => 1 [username] => user [first_name] => hello [last_name] => world ) and
{ user_id: "1", username:"user", first_name:"hello", last_name:"world" } ? , how convert them in php?
edit: add details
actually i'm using redis zunionstore , zrevrange combine user data. result returns me :
array ( [0] =>{"user_id":"1","username":"user","first_name:hello","last_name:world"} [1] => ... ) since have process data, want this:
array ( [0] => array ( [user_id] => 1 [username] => user [first_name] => hello [last_name] => world ) ... ) so there easy way convert instead of using loop json_decode each element? thx
the first string output of print_r function. example:
$array=array('key'=>'value'); print_r($array); outputs:
array ( [key] => value ) your second json-like, alto lacks of double-quotes keys.
can't convert them directly.
you convert json php array json_decode if second string this:
{ "user_id": "1", "username":"user" ... }
Comments
Post a Comment