How to Make a Sentence LowerCase and Replace Spaces with Dash?

[php]
$str = ‘Convert spaces to dash and LowerCase with PHP’;

echo str_replace(‘ ‘, ‘-‘, strtolower($str));
// return: convert-spaces-to-dash-and-lowercase-with-php

[/php]