/ Published in: PHP
URL: http://nothingconcept.com
Expand |
Embed | Plain Text
<?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.
This is simpler:
function str2url($title,$sep = "-"){ $output = strtolower($title); $output = pregreplace("/\s/",$sep,$output); return pregreplace("/[^a-z\d-]/",'',$output); }
hi friend, do you know cheap ghd, cheap mbt shoes, christian louboutin shoes hot sell online recently?
we are china wholesaler company, offer good quality nike dunks, ghd mk4, cheap soccer jerseys online, cheap jerseys online enjoy much discount.cheap nike dunks,nike shox why are you hestitate, welcome for retail, dropship, and wholesale orders.