I have this string:
There 10 items in shop A,
There 30 items in shop B.
I need extract number & text from the string. The result should:
array(
0 => 10 items,
1 => 30 items
);
I tried to use this regex:
\d+\s\/items
But it didn't work.
You should be using preg_match_all:
$string = 'There 10 items in shop A, There 30 items in shop B.';
$matches = null;
preg_match_all('/\d+\sitems/', $string, $matches);
var_dump($matches);
Would output:
array (size=1)
0 =>
array (size=2)
0 => string '10 items' (length=8)
1 => string '30 items' (length=8)
\/in there?