时间:2021-07-01 10:21:17 帮助过:8人阅读
$data = '值1,值2,值3,值4,值5,值6';
$dataArr = explode(',', $data);
foreach ($dataArr as $key => $value) {
if($key%3 == 2){
unset($dataArr[$key]);
}
}
$res = implode(',', $dataArr);
echo $res;
$n = 5; //每 5 个值1,值2,值3,值4,值6,值7,值8,值9,值11
$s = '值1,值2,值3,值4,值5,值6,值7,值8,值9,值10,值11';
$a = explode(',', $s);
foreach ($a as $k => $v) if($k % $n == $n - 1) unset($a[$k]);
$res = join(',', $a);
echo $res;