I have a PHP script with curl’s an external site which returns a javascript array that looks like this:
array[0]=’some stuff’
array[1]=’some more stuff’
I would like to take this and convert it into a PHP array so I can reference it later down in the script for echoing. Is this the way to go about doing it? Is there a better way?
Thanks!
If it’s a String array, you can use regular expressions:
with this:
you can obtain the index, and the value:
i.e, response of curl:
before preg_match, the value of $matches was:
And with something like this:
the $finalArray has the same values of “array”
This code can contain errors.