PHP preg_match_all nested too deeply

alalamiyah

New Member
I found a similar question here but wasn't exact to my scenario.I'm relatively new to PHP but have read the manual for *preg_match_all*.I'm parsing a page to find a date. It's always in the same format (E.g. 13 Apr 2012).This is my *preg_match_all* statement:\[code\]$eventDateRegex = '/[0-9]{2}\s[A-Z]{1}[a-z]{2}\s[0-9]{4}/';preg_match_all($eventDateRegex, $parsedEvent, $eventDates[$i]);\[/code\]$i is just an iterator because it's in a for loop.I'm receiving the correct result in $eventDates, however, it seems to be nested one level too deeply.My result is like this:\[code\]array 0 => array 0 => array 0 => string '19 Apr 2012' (length=11) 1 => string '24 May 2012' (length=11) 1 => array 0 => array 0 => string '21 Apr 2012' (length=11) 1 => string '30 Jun 2012' (length=11)\[/code\]Whereas I'd prefer it to be:\[code\]array 0 => array 0 => string '19 Apr 2012' (length=11) 1 => string '24 May 2012' (length=11) 1 => array 0 => string '21 Apr 2012' (length=11) 1 => string '30 Jun 2012' (length=11)\[/code\]Is this possible or is it just because of the way *preg_match_all* spits out a multi-dimentional array?
 
Back
Top