The ereg() function always matches last occurance of the supplied regular exppression.
Why is this and how can I get it to match the first occurence in the string?
example:
$reg_exp = "^.*([0-9]).*$";
$test_str = " 1, 2, 3, 4, 5 ";
ereg($reg_exp, $test_str, $matches);
echo "Found [".$matches[1]."]<BR>\r\n";
$test_str = " 1, 2, 3, 4 ";
ereg($reg_exp, $test_str, $matches);
echo "Found [".$matches[1]."]<BR>\r\n";
output:
Found [5]
Found [4]