So far I have managed with this:
$link = "";
$longitud = strlen($pais);
for($i = 0; $i<$longitud;$i++){
if($pais[$i] == ""){
$link .= '+';
}else{
$link .= $pais[$i];
}
}
The result would be, for example, if $pais = "Estados Unidos de America"
the variable$link = "Estados+Unidos+de+America"
My doubt is: is there any function to which you can indicate a delimiter and a character or string of characters to replace said type delimiter explode()
but indicating a substitution character
If what you want is to generate a URL you can use urlencode .
If what you want is to do something like what Wordpress does, which is to have a
slug
, you can use something like this:$slug=preg_replace('/[^A-Za-z0-9-]+/', '-', $string);
In that function you can select which would be the "separator". The preg_replace function really gives you a lot of play