开发者

PHP Show Differences

I have two strings:

$stringA = "1,2,3,4";
$stringB = "1,2,4,5";

I want to pick out the values from $stringB that are not in $stri开发者_运维问答ngA.

How can I do that?


A combination of explode and array_diff should get you there.

array_diff(explode(',', $stringB), explode(',', $stringA));


http://pear.php.net/package/Text_Diff/

That should help you out ...


explode() both arrays and use array_diff() to compute differential array.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜