Topic: 3D arrays

Does 3d arrays ($VAR['name']['name2']['name3']) put lots of extra work on the server cpu, ram etc, or are they just like any other arrays?

I'm thinking of using these kind of array-naming to handle multiple userdefined db's, tables etc in a project i'm working on...

Comments?

Re: 3D arrays

well the best way to test this is to enable debug ... and test both types ... then you will be certain ...

as this might be faster for some specific things, and for other things it might be slower, it all depends on what you do, unfortunately.

I've had very odd scripts beeing much faster than one that 'felt' fast when looking at the code. So one shouldn't be surprised on speed issues and php smile

Re: 3D arrays

My thoughs was this:
DEFINE("DBNAME", "somename");
DEFINE("MEMBER_TABLE", "somename2");

$FIELDS['DBNAME']['MEMBER_TABLE']['session'] = "your_own_field_name";

but inside the code, use: $FIELDS['DBNAME']['MEMBER_TABLE']['session'] for the internal structure...

That way you -should- *fingers crossed* be able to make a very pluggable script/module etc in an objectified way and just print out the stuff where you want it via this $obj->printBox(); for instance.

You follow my thought?

Re: 3D arrays

Go for it. Stuff like this very seldom becomes a performance problem anyway.

One thing though. You should not put quotes around defines. $FIELDS['DBNAME']['MEMBER_TABLE']['session'] should be $FIELDS[DBNAME][MEMBER_TABLE]['session']

"Programming is like sex: one mistake and you have to support it for the rest of your life."

5

Re: 3D arrays

there are still quotes around session.

Re: 3D arrays

Yes, but session isn't defined.

"Programming is like sex: one mistake and you have to support it for the rest of your life."

Re: 3D arrays

Ahh, yes of course *missed that*

This way i can: $FIELDS[DBNAME] . $FIELDS[MEMBER_TALBE] . $FIELDS[DBNAME][MEMBER_TABLE]['session']
to build querys that will work with multiple db's, multiple tables and still not break the internat code structure if i wanted to make my script authenticate against say, pun, with pun's username/password fields if i wanted.

I think this approach is very underrated to make code portable because it looks complex when it's really not.

Anyways, now it's StarTreff-time...