public static function makeSerialNumber($str) { if ($str) { //get just the last segment if it includes directory path $str = array_pop(explode('/', $str)); $str = preg_replace('/[^a-zA-Z0-9_-]/', '_', trim($str)); $str = trim(preg_replace('/__*/', '_', $str), '_'); return Dase_Util::truncate($str, 50); } else { return null; } }