Tuesday, December 20, 2011

comparing arrays

The two arrays made with find() look like I would expect them to, but
the foreach loop leaves $discount_prices (of which many have null
values) unaffected. What am I missing here?


//get regular prices
$item_prices = $this->Item->find('list', array('fields' =>
array('Item.price')));

//see if there are any discounts prices for the week's items
$discount_prices = $this->Order->Week->WeeksItem-
>find('list',
array('fields'=>array('item_id','discount_price'),
'conditions'=>array('week_id'=>$week_id)));

//if there is no discount price (value is null), add the regular price
foreach($discount_prices as $key => $discount_price){
if(!isset($discount_price)) $discount_price = $item_prices[$key];
}


--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

No comments: