-3

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!

  • 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
  • 1
    define "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

1 Answers1

0

Thank you people! the json_decode($string, TRUE); solved my problem!