Regular expression is not my strong in PHP and I need your help. I need to transform a string that comes from a post apt to be part of a url. Example:
"Caius did not take a bucket of water" to "fell-did-not-catch-a-bucket" and then he would:
I currently use eregi_replace and PHP 7 does not suit me anymore, so I need a new way to do the same function.
Code:
public static function Url($texto){
$texto = html_entity_decode($texto);
$texto = @eregi_replace('[aáàãâä]','a',$texto);
$texto = @eregi_replace('[eéèêë]','e',$texto);
$texto = @eregi_replace('[iÃÂìîï]','i',$texto);
$texto = @eregi_replace('[oóòõôö]','o',$texto);
$texto = @eregi_replace('[uúùûü]','u',$texto);
$texto = @eregi_replace('[ç]','c',$texto);
$texto = @eregi_replace('[ñ]','n',$texto);
$texto = @eregi_replace('( )','-',$texto);
$texto = @eregi_replace('[^a-z0-9\-]','',$texto);
$texto = @eregi_replace('--','-',$texto);
return strtolower($texto);
}