A little confusing however...
I have a long string somestringDIEmorestringKILLanotherstringDIEmorestring
and I have split that at KILL
so I have the array below:
["valueArray"]
[0] => "somestringDIEmorestring",
[1] => "anotherstringDIEmorestring"
Now I need to split the strings further where it says DIE, however they ideally need to be placed inside a single array so I can loop through them all and post them to their respected endpoints.
Ultimately I need something like this:
["valueArray1"]
[0] => "somestring",
[1] => "morestring",
[2] => "anotherstring",
[3] => "morestring"
OR:
["valueArray1"]
[0] => ["Array"]
[0] => "somestring",
[1] => "morestring"
[1] => ["Array"]
[0] => "anotherstring",
[1] => "morestring"
How is the best way to go about this? I've currently got a $.each
function set up but it's not working correctly:
$.each( valueArray, function( i, val ) {
valueArray1[i] = val.split('DIE');
});
Any help would be awesome! Or equally if there is a better way altogether to sort this out.
Thank you.
NOTE: I have to use strings as it's data coming from localStorage