问题描述
我想将下面这样的字符串转换为数组,我该怎么做?
$icon = '{``font``:``feather``,``icon``:``feather-facebook``}';
使用json_decode或类似的方法有什么办法吗?
谢谢。
解决方法
- 输入的字符串不是正确的json格式
- 当您更正json语法时,您只需对其进行json_decode
$icon = '{"font":"feather","icon":"feather-facebook"}';
$array = json_decode($icon);
var_dump($array);