This question already has answers here:
Answer
Solution:
$string = "[18,23,24,8]";
preg_match_all('/(\d+)/', $string, $m);
var_dump($m);
This will return to you array of matches.
Array (
[0] => Array ( [0] => 18 [1] => 23 [2] => 24 [3] => 8 )
[1] => Array ( [0] => 18 [1] => 23 [2] => 24 [3] => 8 )
)
In you case those will be identical, you can use any $m[0]
, or $m[1]
- doesn't matter.
Source