我在購物車db中有4條記錄。我得到了結果:4444.我如何將結果改爲1234?foreach php邏輯問題
查看:
$i = 0;
foreach($carts AS $cart) {
$x = $i+1;
echo $x;
}
控制器:
function confirm() {
$orders = $this->data;
$sessionId = $this->passedArgs['ct_session_id'];
$this->set('data', $sessionId);
$carts = $this->Cart->find(
'all',
array('conditions' => array('Cart.ct_session_id' => $sessionId), 'recursive' => 1)
);
$this->set(compact('carts', 'orders'));
}
你是怎麼得到444 4反正,這段代碼會產生1111. – tigrang 2012-08-11 18:58:47
'implode('',range(1,4))'但我想這不是,你在找什麼;) – KingCrunch 2012-08-11 23:35:41