| Portada | Monotemáticos | Secciones | Desarrolladores | Comunidad | Servicios | Servicios profesionales | RSS | ||||
| FAQ: Función explode en PHP |
Se muestra un comentario sin revisar
| Enrique | 19/10/06 |
| Si lo quieres a lo burro, aqui te dejo mi funcion xD function destripaUrl($url) { $patternLinks="/(http|https)?(:\/\/)?([a-zA-Z0-9\-\.\_]*\.[a-zA-Z]{2,5})(:[a-zA-Z0-9]*)?(\/?[a-zA-Z0-9\.\-\_]*\/)?([a-zA-Z0-9\-\_\.]+)?(\?[a-zA-Z0-9\.\-\_\?\&\=\%\+\$]+)?/"; preg_match_all($patternLinks, $url, $arrAddress ); $prot =& $arrAddress[1][0]; $addr =& $arrAddress[3][0]; $port =& $arrAddress[4][0]; $fold =& $arrAddress[5][0]; $arch =& $arrAddress[6][0]; $gets =& $arrAddress[7][0]; if ($prot=="" and ($fold=="" or $fold=="/") and $arch=="") { $arch=$addr; $addr=""; } if ($fold=="/" or $fold=="") { if ($arch=="") { $fold="/"; } else { if (!eregi("\.",$arch)) { $fold="/".arreglaUrl($arch)."/"; $arch=""; } else { $fold="/"; } } } $ret = array( "prot"=>$prot,$prot, "addr"=>$addr,$addr, "port"=>$port,$port, "fold"=>$fold,$fold, "arch"=>$arch,$arch, "gets"=>$gets,$gets ); return $ret; } // Quita las barras en el inicio y el fin de la cadena function arreglaUrl($url) { if (strlen($url)>0) if ($url[0]=="/") $url=substr($url,1); if (strlen($url)>1) if ($url[strlen($url)-1]=="/") $url=substr($url,0,strlen($url)-1); $url=str_replace("./","",$url); return $url; } list($prot,$addr,$port,$fold,$arch,$gets)=destripaUrl("http://www.zerodesigners.com/"); |
|
| Ver la FAQ y todos sus comentarios | |
| Añadir un comentario del artículo |
|
Comentarios no revisados de: |