What is the most efficient way of extracting the first two digits in a
string?
The following is wrong for me, because it only gives me the first
instance of two digits together:
$string = ujdk3ca94abc
preg_match("/\d{2}/",$string,$resu lt);
echo "$result[0]";
//prints 94. However, the result I am looking for is 39
Here's another example:
$string = 'abc 8a bc abc934';
//desired result = 89
Thank you.
string?
The following is wrong for me, because it only gives me the first
instance of two digits together:
$string = ujdk3ca94abc
preg_match("/\d{2}/",$string,$resu lt);
echo "$result[0]";
//prints 94. However, the result I am looking for is 39
Here's another example:
$string = 'abc 8a bc abc934';
//desired result = 89
Thank you.
Comment