Hi All,
When I try to run eval("$this->menuArray[2][1] = new menuObj;"), I get the following warning:
Warning: Cannot use a scalar value as an array in /home/HE/web_develop/company_home/www/cgi-bin/includes/menuCL.inc(130) : eval()'d code on line 1
Any attempt to use the object $this->menuArray[2][1] fail, as it wasn't able to properly create the object. Here's the weird part - copying and pasting that code into my file lets it execute perfectly fine.
I'm trying to create an array of menu objects (really just a data object), that is stored in a master control menu object. I want it to be robust enough to be handle any number of menus, at any depth (i.e., an arbitary number of submenus). I'm storing each menu entry in a multidimensional array. Since I'm getting my menu data from a MySQL database, the simplest thing to do seemed ot be to parse out the menu location (which looks something like "2:1:3"), then convert it into the array index form (using the previous example, this would be [2][1][3]). This all works fine except that when I eval the code it bombs out. I don't even totally understand the error - can't use scalar value? What do you mean, can't use scalar values!? I use scalar values for arrays all the time, why can't I use one now? Furthermore, why does it work when I copy and paste that EXACT SAME CODE into the source?
Thoughts anyone? I'm stumped. If eval doesn't work I'll have to rethink my whole paradigm.
BTW, if you want to see the entire class file (which is still heavily under construction), go to
http://www.HeraldicEnterprises.com/menuCL.phpsThe code in question is at the end of the buildMenuObjArray member function (on lines 130 and 137, but that's not necessarily helpful since phps files don't show line numbers)