PHP 5.1.6 ArrayAccess error when iterating over object

Posted by kenny99 on Stack Overflow See other posts from Stack Overflow or by kenny99
Published on 2010-05-13T09:01:31Z Indexed on 2010/05/13 9:04 UTC
Read the original article Hit count: 207

Filed under:
|

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?

                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();
                    }
                }

© Stack Overflow or respective owner

Related posts about php

Related posts about php5