phpRob 10 Posted November 2, 2011 Report Share Posted November 2, 2011 Hi, I'm working through Chapter 7 'Arrays'. Having read about multidimensional arays on w3schools they suggest writing them like so: $books = array( "PHP for the web" => array(1 => "Numbers", "Variables", "Arrays"), "PHP and MySQL" => array(1 => "Databases", "Intro to SQL"), "PHP Advanced" => array(1 => "Introduction to OOP", "Advanced OOP", "Frameworks") ); Larry, do you still object to writing multidimensional arrays this way (nested)? What do you mean when you say it's too easy to make syntactical errors as the statement becomes more and more nested? Thanks Quote Link to post Share on other sites
Josee 38 Posted November 2, 2011 Report Share Posted November 2, 2011 I'm not Larry, but as a fellow PHP-learner I would say that it's much easier to forget a parenthesis or a comma with nested arrays. So, even if it would seem quicker to write it all in one statement, we may just as well waste time looking for a missing comma. Quote Link to post Share on other sites
Larry 433 Posted November 2, 2011 Report Share Posted November 2, 2011 Thanks for the question. I don't categorically advise against writing multidimensional arrays in that way, just for beginners. Once you're quite adept at PHP programming, and are unlikely to make syntactical mistakes, it may make more sense to do things this way. But definitely not when you're first starting. Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.