Hi This is how I need. Let's say that my title is $title="Some text here with many characters,.?/!@#$%^&*()_+| bla bla123"; Code (markup): I want a function that will return only : some-text-here-with-many-characters-bla-bla123 As you can see this will keep only the letters and numbers. I don't need the other characters. I tried this but is not good function cleanurl ( $str ) { $str = urlencode($str); return $str = str_replace( '+', '-', $str ); } Code (markup): This replace the spaces with "-" and encode the other characters
$title="Some text here with many characters,.?/!@#$%^&*()_+| bla bla123"; $result = strtolower(preg_replace('/[^a-z\d]+/i', '-', $title)); PHP:
Great .. works perfect .. Just a little bug If I have the title $title="Some text here with many ” fdg" , How I can do widhout ” ?
obviously you would need to run html_entity_decode before the replacement of characters $title="Some text here with many ©characters,.?/!@#$%^&*()_+| bla bla123"; $result = strtolower(preg_replace('/[^a-z\d]+/i', '-', html_entity_decode($title))); echo $result; PHP:
This works great as before .. I take you to the limit .. If I have this .. The <b>,</b> should not appear .. I think can be done with strip_tags