php排除重复数组与排除重复字符串

<?php function uniqueByChild($array, $child) { $child = "['" . implode("']['", explode(',', $child)) . "']"; $buffer = array(); foreach($array as $index => $value) { eval("/$check = /$value{$child};"); if(in_array($check, $buffer)) { unset($array[$index]); } else { $buffer[] = $check; } } return $array; } $string="33,33,22,22,11,99,00,88,44,55,44,33"; $array=explode(",", $string); $array2 = uniqueByChild($array,''); echo(implode(',',$array2)); ?>

输入:

 

33,33,22,22,11,99,00,88,44,55,44,33

 

输出结果:

 

33,22,11,99,00,88,44,55

 

你可能感兴趣的:(PHP,String,function,buffer)