note 75182 deleted from ref.array by felipe

From: Date: Sun, 30 Dec 2007 19:29:10 +0000
Subject: note 75182 deleted from ref.array by felipe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-134528@lists.php.net to get a copy of this message
Note Submitter: djspy187 at gmail dot com ---- I had an issue with arrays and copying them by reference as follows. // Loop on the list and insert default values foreach ($navigation as &$item) { $children = &$item['children']}; foreach ($children as &$child) { // Do stuff } } This would give me error message Fatal error: Cannot create references to/from string offsets nor overloaded objects in /var/www/dev/kh_system/navigation.php on line 103 Even though $item['children'] is an array. The workaround is to do a for ($i =0;$i < count($Item);$i++) and to then access the children like this $navigation[$i]['children']

« previous php.notes (#134528) next »