如何在PHP中用空间分隔JSON数组 [英] How to separate JSON Array with space in PHP
本文介绍了如何在PHP中用空间分隔JSON数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个JSONArray作为
I have a JSONArray as
{"test":
[
{"Name":"aaa","Reg/Admission Number":"001"},
{...}]}
我可以用...分隔
$read_data = array();
foreach ($data->test as $result){
$name = $result->Name;
$read_data[] = "('$name')";
}
read_data 的结果为('aaa'),('bbb')...
任何人都可以建议如何分隔具有特殊字符'/'和'space'
Anyone can suggest how to separate the array of Reg/Admission Number
which has the special character as '/' and 'space'
推荐答案
根据 @haxxxton 的建议
$read_data = array();
foreach ($data->test as $result){
$name = $result->Name;
$no = $result->{'Reg/Admission Number'}`
$read_data[] = "('$name','$no')";
}
这篇关于如何在PHP中用空间分隔JSON数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文