Hi
The following is the code that I wrote to remove special characters other than alpanumeric characters from a string. The spaces have to be replaced with '-' which I am doing using str_replace. Except for '-' all other special characters have to be removed. So, how should my eregi-replace command should look like?
<?php
$string="asd *&( 096";
if(!(ereg("([0-9])",$string)) || (ereg("([0-9])",$string)))
{
echo "Other characters found\n";
$string=str_replace(' ','-',$string);
echo eregi_replace("([0-9][A-Z])",'',$string);
}
?>
The output that is being given is "asd096", where as the output should be "asd--096", as there are two spaces in between.
Please help me out.
Thanks in advance.