Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Teddy Zugana
Teddy Zugana

Posted on • Edited on

     

PHP seo_friendly_url Example For Slugger

function seo_friendly_url($string){
$string = str_replace(array(‘[\’, \’]’), ”, $string);
$string = preg_replace(‘/[.*]/U’, ”, $string);
$string = preg_replace(‘/&(amp;)?#?[a-z0-9]+;/i’, ‘-‘, $string);
$string = htmlentities($string, ENT_COMPAT, ‘utf-8’);
$string = preg_replace(‘/&([a-z])(acute|uml|circ|grave|ring|cedil|slash|tilde|caron|lig|quot|rsquo);/i’, ‘\1’, $string );
$string = preg_replace(array(‘/[a-z0-9]/i’, ‘/[-]+/’) , ‘-‘, $string);
return strtolower(trim($string, ‘-‘));
}rim($string, ‘-‘));
}

Top comments(2)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss
CollapseExpand
 
bskiefer profile image
bskiefer
  • Joined
function seo_friendly_url($string){    $string = str_replace(array(‘[\’, \’]’), ”, $string);    $string = preg_replace(‘/[.*]/U’, ”, $string);    $string = preg_replace(‘/&(amp;)?#?[a-z0-9]+;/i’, ‘-‘, $string);    $string = htmlentities($string, ENT_COMPAT, ‘utf-8’);    $string = preg_replace(‘/&([a-z])(acute|uml|circ|grave|ring|cedil|slash|tilde|caron|lig|quot|rsquo);/i’, ‘\1’, $string );    $string = preg_replace(array(‘/[a-z0-9]/i’, ‘/[-]+/’) , ‘-‘, $string);    return strtolower(trim($string, ‘-‘));}
CollapseExpand
 
vlasales profile image
Vlastimil Pospichal
  • Joined

Use tripple "`" for enclosure source code.

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

vi veri veniversum vivus vici Noob Teams
  • Location
    Indonesia Jakarta
  • Education
    Computer Science Sriwijaya University
  • Work
    Programmer at Icon Plus, Ezeelink Jakarta
  • Joined

More fromTeddy Zugana

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp