<?php //逗号分割的字符串转换成数组,去重后,转换回以逗号分割的字符串 $strs = '1,2,3,4,5,1,5,1,6,7,1,3,7'; $strs = implode(',',array_unique(explode(',',$strs))); echo $strs;//输出为1,2,3,4,5,6,7