How to replace the hyphen next to the number by underline in that URL (htaccess).
www.site.com.br/post/77-eu_tu_eles
How to replace the hyphen next to the number by underline in that URL (htaccess).
www.site.com.br/post/77-eu_tu_eles
$url = "www.site.com.br/post/77-eu_tu_eles";
$urlExplode = explode("-",$url);
$urlImplode = implode("_",$urlExplode);
With the function explode( string $delimiter , string $string [, int $limit ])
, it will return a array
, the $delimiter
passed, in our case it is the "-". The $delimiter
is used as a parameter for separating the string
.
And soon after we use implode ( string $glue , array $pieces )
, where we get the array
returned from the explode
function, which is stored in the variable $urlExplode
, and pass $glue
to merge% , which in this case is "_".