Self-Test Questions in PHP Language For Beginners Part 8


1. PHP doesn’t support multidimensional arrays natively, so what is the process of emulating such a structure?
2. What kind of array structure would you create to hold the contents of a 3×3 Tic-Tac-Toe board?
3. Given the array $oxo, containing a 3×3 Tic-Tac-Toe board, how might you reference the element in the top-left corner? How about the bottom-right corner?
4. How can you pre-increment a numeric value stored in an associative array at $PageClicks['homepage']?
5. How can you post-decrement a numeric value stored in an associative array at $PageClicks['homepage']['menu']?
6. How might you populate an associative array called $marbles with three sizes of marbles (small, medium, and large), of which you have (in order) 17, 23, and 21 bags?
7. How might you create a similar array to the $marbles array in Question 6, but with each array element containing a sub-array (rather than a numeric value), suitable for storing additional information?
8. What is one way you could access the second-level array elements for the $marbles array in Question 7 to also store information for the marble colors (red, green, and blue), along with their matching stock quantities?
9. Assuming all the elements for the array in Question 8 have been assigned values for the three sizes, three colors, and stock quantities, how could you determine the stock level of medium-sized bags of blue marbles?
10. Given a value stored in an associative, two-dimensional array, at $marbles['large']['red'], how can you increment this value by 10 with a single statement?

Self-Test Questions in PHP Language For Beginners Part 8

No comments:

Post a Comment