921025 发表于 2016-4-6 15:51:51

php处理字符串

比如:
$a = '1,2,3,4,5,6';
$b = '4,5,6,7';
如何将重复的值去掉,变成下面这样
$newnum = '1,2,3,7';

一叶扁舟 发表于 2016-4-6 16:23:14

$a = explode(',', $a);
$b = explode(',', $b);
$temp1 = array_diff($a, $b);
$temp2 = array_diff($b, $a);
$newnum = array_merge($temp1, $temp2);
$newnum = implode(',', $newnum);

921025 发表于 2016-4-9 18:02:20

感谢。:handshake
页: [1]
查看完整版本: php处理字符串