2011-05-05 16 views

回答

4

試試這個:

// Remove all non-numeric characters: 
function removeStuff($string) { 
    return preg_replace('/[^0-9]/', '', $str); 
} 

strcmp(removeStuff($str1), removeStuff($str2)); 
2
if (preg_replace('/[^0-9]+/', '', $str1) == preg_replace('/[^0-9]+/', '', $str)) { 
    // They're equal, do whatever you want! 
} 

這將測試兩個字符串被剝離除0-9之外的任何東西。