Thanks,
To make sure I'm undersatnding correctly, you can not change the
values in an array that is being scanned by foreach, you need to send
changes based on the scan to a new variable?

This worked
$weeks_prices = array();
                foreach($discount_prices as $key => $discount_price){
                        if(!isset($discount_price)) $weeks_prices[$key] =
$item_prices[$key];
                        else $weeks_prices[$key] = $discount_price;
                }

On Dec 20, 8:14 am, euromark <dereurom...@googlemail.com> wrote:
> basic php
> you cannot override $discount_price locally and expect it to change
> anything outside of the loop and the scope of this change
>
> if(!isset($discount_price)) $discount_prices[$key] =
> $item_prices[$key];
>
> On 20 Dez., 16:37, roundrightfarm <roundrightf...@gmail.com> wrote:
>
>
>
>
>
>
>
> > 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+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php

Reply via email to