How can I check if a string ends with a number, and if true, push the number into an array (for example)? I know how to check if a string ends with a number, I solved it as follows:
$mystring = "t123";
$ret = preg_match("/t[0-9+]/", $mystring);
if ($ret == true)
{
echo "preg_match <br>";
}
else
{
echo "no match <br>";
}
Suppose that all lines begin with a letter tand are composed with a number, for example. t1, t224, t353253...
But how can I cut out this number, if any? In my example code, there is 123at the end of the line, how can I cut it and, for example, click on an array with array_push?
Black source
share