Published in: PHP
URL: http://nothingconcept.com
<?php function str2url($title,$sep = "-"){ $exclude = array("!","@","#","$","%","^","&","*","(",")","=","{","}","[","]","|","\\","/","?","<",">","~","`","_","+","=","-"); $output = NULL; foreach($pieces as $key => $val){ if($pieces[$key+1] == NULL){ $sep = NULL; } $output .= $val.$sep; } return $output; } ?>
Comments
Subscribe to comments
You need to login to post a comment.

Why are you not just using PHP's "urlencode" function (php.net/rawurlencode or php.net/urlencode) ? I don't get the point of this snippet ...
This is to convert a string to be used as something like a permalink/post slug. Blog software (like Wordpress) does this. I just made this as a simple function one could use in one's own software.
This function is fine as long as you are handling cases where the slug returned is not unique separately
In the above case , $a and $b will be the same, yes ?
Sorry - what I was tring to say is for the string "Evan Walsh Rocks!" and "Evan Walsh Rocks?" you would get the same result.