{
"receiver_uid":[
"58a43a3e3fbbf3.61108490",
"58a43be07a3bc3.90311110",
"58da53ab5ce8d6.84754819"
]
}
這是我想要轉換爲數組的值。我知道這是一個非常簡單的問題,但請任何人都可以幫助我?如何將JSON數組轉換爲PHP中的數組?
{
"receiver_uid":[
"58a43a3e3fbbf3.61108490",
"58a43be07a3bc3.90311110",
"58da53ab5ce8d6.84754819"
]
}
這是我想要轉換爲數組的值。我知道這是一個非常簡單的問題,但請任何人都可以幫助我?如何將JSON數組轉換爲PHP中的數組?
使用json_decode
json_decode($your_jsonString,true)
您應該使用json_decode
。
試試這個:
$data = json_decode($your_json_string, TRUE);
的第二參數將使解碼JSON字符串的關聯數組。
例子: -
$data = '{"receiver_uid":["58a43a3e3fbbf3.61108490","58a43be07a3bc3.90311110","58da53ab5ce8d6.84754819"]}';
$array = json_decode($data, true);
echo "<pre>";
print_r($array);
輸出會像
Array
(
[receiver_uid] => Array
(
[0] => 58a43a3e3fbbf3.61108490
[1] => 58a43be07a3bc3.90311110
[2] => 58da53ab5ce8d6.84754819
)
)
@ MarshallS.Lee如果幫助,請將回答標爲接受。謝謝 :) –
使用'json_decode'方法 – C2486
@SahilGulati我知道,但我真的很迫切需要得到的答案。 –
嘗試使用@NishantNair的帖子 –