php to write code for it self depending on the input....

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Calimero
Forum Contributor
Posts: 310
Joined: Thu Jan 22, 2004 6:54 pm
Location: Milky Way

php to write code for it self depending on the input....

Post by Calimero »

This little :twisted: :twisted: :twisted: baby, ehm !

Gave me "little" problems, did it any possible way I could think of, but couldn't find a solution.

Here it goes: :arrow:

Is there a way for php to create the following

multi-dimensional array, but how deep ( how many [][][][] ) are calculated on the input parameters ( 10 - will give ten-levels deep )

it is very easy for 2 levels - two FOR loops and finished, but - I don't think that my machine would react positively on lets say 20 FOR in FOR loops or how ever many user inputs.

So is there any easier way to do this.


Any ideas would be very helpful !
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

why don't you give it a try first? i would be surprised if looking up 10 indices would ask that much significant cpu cycles...

otherwise, you can create an array with 1 dimension.

and calculate yourself where [$i][$j] is.

because, it's the same as ($i * sizeof dim1) + $j

and [$i][$j][k$] is the same as ($i * sizeof dim1) + ($j * sizeof dim2) + $k

and so on...
Post Reply