Please I have the flowing string :
$str = 'blabla-blabla - 12345, blobl-ooo - 54123, hihihi - 98745';
I want to get in an array blabla-blabla – 12345 and blobl-ooo – 54123 and hihihi – 98745
To do that I’m thinking to use REGEXP so I’ve tried :
preg_match_all("/\b[\p{L}'-]+|[a-z]+\b/u", $str, $all);
but this get only the string part and not the numbers.
Please any advice masters ?
PS : I can’t use list and explode because I don’t know the number of elements in my string.
For your regex, try:
\w deals for all letters or digits, and the \d for all digits.
Otherwise, even if you do not know the size of your string, you can use explode: