I need to get the amount before a :- sign. So the string would be: bla bla 120:-
And then store only 120 in a variable
I need to get the amount before a :- sign. So the string would be: bla bla 120:-
And then store only 120 in a variable
preg_match_all('!(\d+):-!', $string, $matches);
print_r($matches);
This should do it. It captures anything up to a whitespace before ":-"
The regex
/(-?\d+):-/
will capture any digits (and a negative sign, if it's there) before a ":-" in the string.
You can than parse that into a number and store it.