I have the following input:
a few words – 25
some more – words – 7
another – set of – words – 13
And I need to split into this:
[0] = "a few words"
[1] = 25
[0] = "some more - words"
[1] = 7
[0] = "another - set of - words"
[1] = 13
I’m trying to use preg_split but I always miss the ending number, my attempt:
$item = preg_split("#\s-\s(\d{1,2})$#", $item->title);
Use single quotes. I cannot stress this enough. Also
$is the string-end metacharacter. I doubt you want this when splitting.You may want to use something more like
preg_match_allfor your matching:Produces:
Think you can glean the information you need out of that structure?