Advertisement
niammuddin

function seo_friendly_url

Jul 27th, 2017
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.53 KB | None | 0 0
  1. <?php
  2. function seo_friendly_url($string){
  3.     $string = str_replace(array('[\', \']'), '', $string);
  4.     $string = preg_replace('/\[.*\]/U', '', $string);
  5.     $string = preg_replace('/&(amp;)?#?[a-z0-9]+;/i', '-', $string);
  6.     $string = htmlentities($string, ENT_COMPAT, 'utf-8');
  7.     $string = preg_replace('/&([a-z])(acute|uml|circ|grave|ring|cedil|slash|tilde|caron|lig|quot|rsquo);/i', '\\1', $string );
  8.     $string = preg_replace(array('/[^a-z0-9]/i', '/[-]+/') , '-', $string);
  9.     return strtolower(trim($string, '-'));
  10. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement