How to format text for URL pattern?

How to format text for URL pattern?

$australianbrother = "Long Life Australia";

The value has to come out in the pattern below


Thank you very much in advance

That looks like a job for strtolower and str_replace. Assuming longi-life-australia is a typo.

What is the real problem you are trying to solve?

The result is called a slug. You can create a simple function yourself, but it can get quite hair when you get into different encodings etc. It’s easier to use something others have already created, like the
Slugger in the Symfony String component.


This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.