-3
$a = "what go around, come around";
$b = "what goes around, comes around";
返回不同的值進行比較$a
和$b
時,它將從$b
即從$a
不同返回數組$arr = {"goes","comes"}
。請建議一個解決方案比較兩個串和在PHP
$a = "what go around, come around";
$b = "what goes around, comes around";
返回不同的值進行比較$a
和$b
時,它將從$b
即從$a
不同返回數組$arr = {"goes","comes"}
。請建議一個解決方案比較兩個串和在PHP
只需使用preg_split
與array_diff
一起等作爲
$a = "what go around, come around";
$b = "what goes around, comes around";
echo implode(',',array_diff(preg_split('/\h/',$b),preg_split('/\h/',$a)));
輸出:
goes,comes
嘗試玩PHP array_diff()功能。
array array_diff (array $array1 , array $array2 [, array $... ])
它比較array1
對一種或多種其它陣列並返回array1
中不存在於任何其它陣列的值。
[?你嘗試過什麼(http://mattgemmell.com/你試過什麼/) – Epodax
你想完成什麼? –
'$ arr = array_diff(str_word_count($ b,2),str_word_count($ a,2));' –