Mar 24

Most of the developers nowadays prefer to rewrite URLs for (Search Engine Optimization)SEO. This code is sample on how to strip symbols from a string.

<?php
function urify($str){
  return str_replace(" ","-",trim(ereg_replace("[^A-Za-z0-9[:space:]]", "", $str)));
}
$string = "I really hate symbol on my URL - 12345 What the !£$%^& ~!@#$%^&*()_+=-[]{}";
echo urify($string);
?>

Output is:
I-really-hate-symbol-on-my-URL–12345-What-the

Tagged with:
preload preload preload
Bless CV