I have the following code in a while loop - the strings its parsing look like "Event 10 Men's 800 Yard Run". I want it to split the string after the event number, and have the event name below it. So like: Event 10 Men's 800 yard run The problem is, $events[0] does not hold any information - $events[1] holds Men's 800 Yard Run, but I cannot get it to store Event 10. Help please $events = preg_split("/Event\x20[0-9]{2}/", $element, PREG_SPLIT_DELIM_CAPTURE); echo $events[0]." <br /> ".$events[1]." <br />"; PHP: print_r($events) yields Array ( [0] => [1] => Men's 800 Yard Run ) Code (markup):
With preg_split, the regular expression defines the delimter or "needle". Since there is nothing preceeding the delimeter in your "haystack", the first array element is empty. I think preg_match() would be a better choice for you.