日期:2014-05-17 浏览次数:20520 次
$s = '12_1_5_10'; $r[] = strtok($s, '_'); for($i=0; $t = strtok('_'); $i++) { $r[] = $r[$i] . '_' . $t; } print_r($r);
------解决方案--------------------
还是老大猛,我的就是裹脚布
$str = '12_1_5_10';
$array = explode('_', $str);
$newarr = array();
for ($i = 0; $i < count($array); $i++) {
$newarr[]=array_slice($array,0,$i+1);
}
foreach($newarr as $value){
echo '<pre>'.implode('_',$value).'</pre>';
}