Uso:
echo buildUrl("Esto es una prueba á à ó ñ "); |
regresa: Esto_es_una_prueba_a_i_o_n
function buildUrl($name){ $name = strtr($name, "áéÃóúñÃÉÃÓÚÑ ", "aeiounAEIOUN-"); $values = array('A', 'B', 'C', 'D', 'E', 'F', 'G' ,'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, '-'); $out = ""; $len = strlen($name); for($chr=0;$chr<=$len-1;$chr++){ if(in_array($name[$chr],$values,true)) $out.= $name[$chr]; } return $out; } |
Build url friendly from the title with PHP
apenas 1 comentario ↓
amigo debe arreglar
for($chr=0;$chr<=$len-1;$chr++){
por
for($chr=0;$chr<=$len-1;$chr++){
Leave a Comment