I want to get the two numbers in a string
Example: the user input "what is 177 x 55", then I want to get 177 and 55
$number1 = 177;
$number2 = 55;
I want to get the two numbers in a string
Example: the user input "what is 177 x 55", then I want to get 177 and 55
$number1 = 177;
$number2 = 55;
You can use regex for this.
Regex will match and capture in strings according to a pattern, in this case the pattern is a simple any size digit.
preg_match_all("/(\d+)/", $string, $matches);
list($number1, $number2) = $matches[1];
The regex will capture any number of numbers in the string ("155 x 25 x 40" for example), but the list() function is the limiting factor here.
If there is three numbers in the list() will fail.
So I recommend you to use the array instead of the list($number1, $number2)
.