I have a plain text journal I’m trying to format in php. I’d like to split each entry into an array containing date and text.
Using preg_split I can do this, however it removes the date altogether!
The txt file looks something like this:
2012-01-28
text text text
2012-01-14
some other text
2011-12-07
a previous entry
etc.
the
PREG_SPLIT_DELIM_CAPTUREflag will prevent your dates from being removed when you split, as long as the date is parenthesized in your pattern string. e.g.:Now your dates are in the odd indices of the array and your content is in the even indices.