I'm listing out some dates in my PHP application which results in something like the following:
April2016May2016June2016
etc.
I'm trying to use preg_split
to format them like this:
array('April 2016', 'May 2016', 'June 2016')
I used an online Regular Expression editor to determine how to detect for 4 consecutive numbers and here's how far I've gotten:
Note: I am also removing all white space - ideally this would be better if it only removed white space if there were more than 2 spaces i.e. hello world
would not be altered but hello world
would.
preg_split('/\d\d\d\d/g', preg_replace('!\s+!', '', $sidebar_contents));
Using the above, I get an error suggesting that the g identifier is not valid assuming because it's not preg_match_all
- removing the g result in the following:
Thanks for any help!