开发者

PHP Show Differences

开发者 https://www.devze.com 2023-01-09 01:46 出处:网络
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.

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

精彩评论

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

关注公众号