Symfony 5 : How to use a php function? [closed]

I’m new to symfony and I have a question!

How use this PHP function in my controller by Symfony ?

function slugify($string, $delimiter = '-') {

   $oldLocale = setlocale(LC_ALL, '0');
   setlocale(LC_ALL, 'en_US.UTF-8');
   $clean = iconv('UTF-8', 'ASCII//TRANSLIT', $string);
   $clean = preg_replace("/[^a-zA-Z0-9/_|+ -]/", '', $clean);
   $clean = strtolower($clean);
   $clean = preg_replace("/[/_|+ -]+/", $delimiter, $clean);
   $clean = trim($clean, $delimiter);
   setlocale(LC_ALL, $oldLocale);
   return $clean;
}

In my controller, the goal is to be able to use this function to format the url.

Thank’s 😉

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *