php数组foreach出来如何控制里面的顺序?
<?php<br /> /*查询关键字5个宝贝,按照热销降序排列*/<br /> $items = $itemManager->queryByKeyword(" ","hotsell",5);<br /> foreach($items as $i=>$item){<br /> echo "宝贝标题:". $item->title;<br /> }<br /> ?>
$items = array(1,2,3,4,5);<br /> <br /> foreach($items as $v) echo $v;<br /> echo '<br>';<br /> <br /> $items[] = array_shift($items); <br /> foreach($items as $v) echo $v;<br /> echo '<br>';<br /> <br /> $items[] = array_shift($items); <br /> foreach($items as $v) echo $v;<br /> echo '<br>';<br />