How to format text for URL pattern?

How to format text for URL pattern?

<?php
$australianbrother = "Long Life Australia";

The value has to come out in the pattern below

longi-life-australia

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.

See https://symfony.com/doc/current/components/string.html#slugger