时间:2021-07-01 10:21:17 帮助过:12人阅读
$ar = array( 0 => '今天吃了吗!', 2, '今天不吃了!', 3, '今天真饿啊!', 8, ); foreach(array_chunk($ar, 2) as $v) $list[] = array( 'id' => $v[1], 'name' => $v[0] ); print_r($list);
------解决方案--------------------
$array = array('标题1', 'id1', '标题2', 'id2', '标题3', 'id3'); foreach ($array as $key => $value) { if (isset($array[$key + 1])) $id = $array[$key + 1]; echo '' . $value . ' (id=' . $id . ')
'; }
------解决方案--------------------
$array=array(); $arrList=array(); for($i=0; $i------解决方案--------------------
$array = array('id1','标题1','id2','标题2','id3','标题3'); foreach(range(1,count($array)*1/2) as $val){ echo "".next($array)."\r\n"; next($array); }