I have strings that I’m printing as:
$string = "winter coats gloves hats blankets sleeping bags tarps milk magnesia shoes boots art";
That I need to regex into a string array, like:
$newString = array ('winter','coats','gloves','hats','blankets','sleeping','bags','tarps','milk','magnesia','shoes','boots','art');
The challenge is, how to add only ' on each end, while ',' to replace the spaces…
So far I have this, which doesn’t work…
$string = str.replace(/\s+/g, '','',$string);
If I don’t misunderstand you, simply:
This will create a string array out of your string.
explode() in PHP Manual
What you have tried does not work because it is Javascript. If you clarify a bit what you’re trying to achieve exactly, and how Javascript comes into the picture, we could help further.