I am getting strings from a database and then using the strings to build a URL. My issue is, some of the strings will have characters like < > & { } * general specia
$search_value =array(",",".",'"',"'","\\"," ","/","&","[","]","(",")","
{","}",":","`","!","@","#","%","=","+");
$replace_value =array("-","-","-","-","-","-","-","-","-","-","-","-","-","-","-","-
","-","-","-","-","-");
$product_name = str_replace($search_value,$replace_value,$row["Product_Name"]);
$product_name = str_replace("--","-",$product_name);
$product_name = str_replace("--","-",$product_name);
$product_name = preg_replace('/-$/', '', $product_name);
$product_name = preg_replace('/^-/', '', $product_name);
This will create dashed string (Only have alphanumeric character with dash).Useful for create URI strings.