Convert string to underscore_name
Converts " Peter's nice car " to "peters_nice_car".
Converts "_88" to "88"
1 2 function string_to_underscore_name($string) 3 { 4 $string = preg_replace('/[\'"]/', '', $string); 5 $string = preg_replace('/[^a-zA-Z0-9]+/', '_', $string); 6 $string = trim($string, '_'); 7 $string = strtolower($string); 8 9 return $string; 10 }