Please help me to convert this code to preg_match in php since it issues "Function ereg() is deprecated " error.
[php]
function isValid($type,$var) {
$valid = false;
switch ($type) {
case “CustomerName”:
if (ereg(’^[A-Z][- a-zA-Z]+$’,$var)) {
$valid = true;
}
break;
case "ContactPersonName":
if (ereg('^[A-Z][- a-zA-Z]+$',$var)) {
$valid = true;
}
break;
case "contact1":
if (ereg('/^[0-9]{10}$/',$var)) {
$valid = true;
}
break;
case "contact2":
if (ereg('/^[0-9]{10}$/',$var)) {
$valid = true;
}
break;
case "email":
if (ereg('/^[a-z0-9][a-z0-9_.-]*@[a-z0-9.-]… {
$valid = true;
}
break;
}
}
[/php]
when I run this in firefox , the out put always like this : Deprecated: Function ereg() is deprecated in C:\wamp\www\Testing\new_cust2.php on line 34
(same for the other lines also)
Please help me with this