我想处理JSON数据结构,可能看起来像这样:
$json = {"1":"some content here","hello":"world"};
我使用PHP中的json_decode方法将其转换为数组:
$myArray = (array)json_decode($json);
我现在的问题是
unset($myArray["1"]);
不做任何事情。
你能给我一些建议吗?我也试过:
unset($myArray[(String)"1"]);
谢谢!
编辑:我的问题中有一个错误,感谢您在评论中的更正!我想你只是访问了错误的数组
unset($myArray["1"]);
unset($myArray[1]); // works also