-5

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>';
}
mickmackusa
  • 37,596
  • 11
  • 75
  • 105
John
  • 1,161
  • 1
  • 11
  • 31

1 Answers1

3

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>';
}
shushu304
  • 1,466
  • 1
  • 6
  • 15