I am sending a Array from PHP encoded it to JSON and send it to a JavaScript value.
Now I wanted to split the Array on comma’s ,.
This worked fine, but when calling the very first and last string inside the array I can see a [, ] and ".
I can get the " gone, but the [ and ] seems to be a problem.
my code now:
data_array[i].replace(/["[]]/g,"");
If you transfer a string value like
"[5,4,7,2,1]"from PHP to Javascript, you should ratherJSON decodeit into a native Javascript object/array.From that point on, you may just access
receivedDatalike a normal Array