3 ms·
You should absolutely spend a day or two working with multi-dimensional arrays. It really is a core skill, like debacle said. A few simple things you can try:
by whichdan 14y ago
You should absolutely spend a day or two working with multi-dimensional arrays. It really is a core skill, like debacle said.
A few simple things you can try:
- Design a database for a forum. Use PHP to pull a list of Users. For each User, pull the top 5 Posts, and for each Post, pull the Topic they posted in, and for each topic, pull the most recent Post and User who replied. That's 3 levels deep.
- Create a list of 10 major Cities in your country, and for each City, list the Average, High, and Low temperatures for two different Dates. That's 2 levels deep.
- Create a database for a store. For each Product, pull a list of the 10 most recent Purchases. For each Purchase, pull the User, and for each User, pull a list of their 10 most recent Purchases, and for each of these Purchases, pull the Products that were Purchased. That's 4 levels deep.
These are all very real-world scenarios, and if you can design and code them all, you'll have no problems working with any other multi-dimensional arrays.
I would also highly recommend writing the code to display the data from each array in a hierarchical table, and make sure you know how to access a single value directly, such as the Lowest temperature for a given Date in a City.
- orangethirty 14y agoI can do that with no problem. That is why it is frustrating. Nerves got the best of me. That is why I said I don't know. I was nervous. And under the circumstances I did not know the answer. But later on I went and did the exercise by myself with not much hassle.
- whichdan 14y agoSo the moral of the story is: keep interviewing until you start feeling confident :)
- orangethirty 14y agoWell, you have opened up my eyes. Thank you.