douyangqian5243 2017-12-04 20:16
浏览 28
已采纳

PHP字符串数组到php数组[重复]

This question already has an answer here:

I have this string array:

["652","110","111","1032","118","416","147","121","112","1033","113","1031","868"]

I need to read each value so to get

652
110
111
1032

i try to convert string array using explode and then foreach but is not working...

$channels = explode('"', $string_array);

foreach($channels as &$channel) {
    echo $channel.'<br>';
}
</div>
  • 写回答

1条回答 默认 最新

  • douliao5942 2017-12-04 20:19
    关注

    it's an JSON format, so use json_decode

    $json = '["652","110","111","1032","118","416","147","121","112","1033","113","1031","868"]';
    $array = json_decode($json, true);
    foreach($array AS $channel) {
        echo $channel.'<br>';
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?