日期:2014-05-17 浏览次数:20450 次
$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 '<a href="?id=' . $id . '">' . $value . '</a> (id=' . $id . ')<br/>'; }
------解决方案--------------------
$array=array(); $arrList=array(); for($i=0; $i<count($list); $i++){ $array['title'] = $list[$i]; $array['id'] = $list[$i+1]; $arrList[] = $array; } foreach($arrList as $lists){ echo "<a href='?id=$lists['id']'>$lists['title']</a>"; }
------解决方案--------------------
$array = array('id1','标题1','id2','标题2','id3','标题3'); foreach(range(1,count($array)*1/2) as $val){ echo "<a href='?id=".current($array)."'>".next($array)."</a>\r\n"; next($array); }