Is there a simple way to convert this:
$string = "[4164,8720,10303,10340,10627]"
to an actual array? I know that i can use explode and implode, but when i receive huge string like above, i have some speed issues with my web site. Any help is appreciated!
Asked
Active
Viewed 29 times
-3

Kuanish Aitimov
- 17
- 2
-
That data is valid JSON, so you can simply use `json_decode`. – CBroe Jun 23 '22 at 09:49
-
try : $ar = json_decode($string, TRUE); – svgta Jun 23 '22 at 09:49
-
1define "huge". Define "speed issues". What exactly is the size of the data which causes problems, and what exactly happens? In this specific case you could use json_decode. explode won't entirely do the job here anyway because of the square brackets, you'd need to trim them first. – ADyson Jun 23 '22 at 09:49