-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
  • 43,625
  • 12
  • 83
  • 136
John
  • 1,521
  • 3
  • 15
  • 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,506
  • 1
  • 7
  • 15