- preg_replace: documentation ( source)
- strtolower: documentation ( source)
<?php
$text = "234pLdfv";
$text = preg_replace('~[^pLd]+~u', '-', $text);
$text = iconv('utf-8', 'us-ascii//TRANSLIT', $text);
$text = strtolower($text);
// remove unwanted characters
$text = preg_replace('~[^-w]+~', '', $text);
if (empty($text))
{
echo 'n-a';
}
echo $text;