View Full Version : PHP ereg();
Halting
21-10-2006, 05:59 PM
Hey,
I want to use the ereg function to find MSIE followed by any number between 0 and 7.0. For instance MSIE 5.01. What would be the valid regular expression for this?
Thanks in advance,
Olii
<?php
$input = "MSIE 5.01";
$eimput = explode(" ", $input)
$num = $eimput[1];
ereg ("([0-7]{1}).([0-99]{2,1})", $num, $finout);
echo "Returned: ";
echo $finout[1];
echo ".";
echo $finout[2];
?>
Not tested, may not work.
:Blob
21-10-2006, 08:13 PM
<?php
$input = "MSIE 5.01";
$eimput = explode(" ", $input)
$num = $eimput[1];
ereg ("([0-7]{1}).([0-99]{2,1})", $num, $finout);
echo "Returned: ";
echo $finout[1];
echo ".";
echo $finout[2];
?>
Not tested, may not work.
Nope :D
Parse error: syntax error, unexpected T_VARIABLE in /home/shake/public_html/Tom/index.php on line 4
Huddle
21-10-2006, 10:52 PM
I got it too.
Try:
<?php
$input = "MSIE 5.01";
$eimput = explode(" ", $input)
$num = $eimput[1];
if(ereg ("([0-7]{1}).([0-99]{2,1})", $num, $finout)){
echo "Returned: ";
echo $finout[1];
echo ".";
echo $finout[2];
}
?>
Want to hide these adverts? Register an account for free!
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.