2013-02-15 266 views

回答

4

strtolower($string1) == strtolower($string2)

+0

啊,完美。謝謝! – 2013-02-15 08:27:57

2

strcasecmp (string $str1 , string $str2)忽略的情況下,返回0,如果相等則

1
strcmp (strtolower($str1) , strtolower($str2)) 
1

試試這個,

$str1 = 'harrisburg'; 
$str2 = 'HARRISBURG'; 

選項1:如果$str2值是大寫的。

strtolower('$str2'); 

更多細節strtolower — Make a string lowercase

選項2:不區分大小寫比較

strcasecmp ($str1 ,$str2) 

爲maore細節strcasecmp — Binary safe case-insensitive string comparison

注(供選擇-2)Returns < 0 if str1 is less than str2; > 0 if str1 is greater than str2, and 0 if they are equal.

這可以幫助你。

+0

解決方案需要使用正則表達式時,我們已經有了strtolower,strcasecmp可用:) – 2013-02-15 07:40:09

0

顯然這是在PHP中的一個函數?該函數將返回兩個傳遞的字符串之間的相似度值。不是OP要求的內容,但考慮到問題標題,認爲這將是一個相關的答案。

similar_text(str1, str2)

相關問題