Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.
Daniel Fitzhugh9,715 Points
Why does array_rand() return a "meta-array" of keys, and not just the original array with a reduced number of items ?
I noticed a recurring theme with the videos in this course regarding how to "filter" or "select a subset" from a master array. I've seen the same confusing technique in both of these videos:
The teacher always seems to create a "meta-array" of keys, and then juggles the parameters (in a really confusing way) to get the results that she wants.
Would it not be easier --- especially for this task, "Random fun with arrays" --- if array_rand() just produced an array which was similar in structure to the master array, which we could then iterate through using a "foreach" loop, without having to do all of the confusing parameter juggling that the teacher does whenever she uses her preferred technique ?
Sorry if this is confusing.... it confuses me also :)