I upgraded to PHP 5.3 and i got the error: ereg has been deprecated.
What can i use to replace this??
function CheckIfAlphaNumberic($text) {
if (ereg('[^A-Za-z0-9]', $text)) {
unset ($text);
}
return $text;
}
You can use preg_match()
:
function CheckIfAlphaNumberic($text){
if (preg_match('#[^A-Za-z0-9]#', $text)) {
unset ($text);
}
return $text;
}
See also: Switching From ereg to preg
Furthermore, you may use return null;
instead of unset ($text);