- str_replace: documentation ( source)
- wordwrap: documentation ( source)
- strtolower: documentation ( source)
<?php
$str = 'Convert spaces to dash and LowerCase with PHP';
$separator = '-';
$str_replace = str_replace(' ', $separator, strtolower($str));
$wordwrap = wordwrap(strtolower($str), 1, $separator, 0);
echo 'Original: ' . "\t" . $str . "\n";
echo 'str_replace: ' . "\t" . $str_replace . "\n";
echo 'wordwrap: ' . "\t" . $wordwrap . "\n";