2015-12-21 84 views
0

我試圖用xdiff_string_diff()函數像下面找到新舊字符串之間diffrence:xdiff_string_diff()函數返回致命錯誤

$old_str="Hello world"; 
$edited_str="Hello ladies!"; 
echo xdiff_string_diff($old_str,$edited_str,1); 

我的服務器返回一個致命錯誤:

Call to an undefined function 

我的php版本是5.4 *

問題是什麼?

我需要在我的服務器上安裝某些東西才能使此功能正常工作嗎?

請幫忙!

+0

你需要安裝'xdiff'。在你的控制檯輸入'pear install xdiff' – jitendrapurohit

+0

[String difference php](http://stackoverflow.com/questions/12002132/string-difference-php) – jitendrapurohit

回答

2

您必須安裝xdiff

pecl install xdiff 

或土特產品可以試試這個:

$a1 = explode(" " , 'Hello world'); 
$a2 = explode(" ", 'Hello ladies!'); 

echo join(' ', array_diff($a1, $a2)); // output :- world