- array_chunk: documentation ( source)
- implode: documentation ( source)
- explode: documentation ( source)
- trim: documentation ( source)
<?php
$s = "123, 123, 456, 456, 123, 123";
$arr = explode(",", $s);
$str ="";
Foreach(array_chunk($arr,2) as $sub){
$str .= trim(implode(",",$sub)) .",<br>\n";
}
Echo $str;