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

  function, php, symfony, symfony5

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