|
Posted by Erwin Moller on 07/25/06 08:37
David T. Ashley wrote:
> Hi,
>
Hi,
> Aside from the obvious recursive syntax for initialization,
>
> $x = array( ... array( ...)),
>
> what is the best way to deal with multi-dimensional arrays in PHP?
That question is too general to give a sensible answer.
It depends on what you need to accomplish.
eg: You can use the hash indexing, or the normal (integer) indexing.
Why should 1 be better? Depends on your situation.
If you are using a database an associative indexing could make sense for
rows. In other situations the integer indexing makes more sense.
>
> It seems there is no syntax like $x[i][j][k]???
Yes there is.
>
> Thanks, Dave.
Dave, read this:
http://nl2.php.net/manual/en/ref.array.php
It will clear up a lot of questions.
And one tip: In my experience: Instead of thinking of multidimensional
arrays, it is often simpler and clearer to think of arrays that contain
arrays.
Regards,
Erwin Moller
Navigation:
[Reply to this message]
|