tags:

views:

49

answers:

0

Hi, I'm having to develop a site on PHP 5.1.6 and I've just come across a bug in my site which isn't happening on 5.2+. When using foreach() to iterate over an object, I get the following error: "Fatal error: Objects used as arrays in post/pre increment/decrement must return values by reference..."

Does anyone know how to get around this issue?

            $f_type = new Feeding_type_Model;
            $f_type->type = $post['feeding_type'];
            $f_type->quantity = $post['quantity'];
            $f_type->feeding_id = $feed->id;
            $f_type->save();

                if (strpos($post['feeding_type'], 'comm'))
                {
                    foreach ($post['commercial_brands'] as $brand)
                    {
                        $comm_food = new Commercial_food_Model;
                        $comm_food->brand = $brand;
                        $comm_food->feeding_type_id = $f_type->id;
                        $comm_food->save();
                    }
                }