Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP Integrating PHP with Databases Querying the Database with PHP Working with Query Results

Array Keys [0], [1]. [2] Vs. [101], [102], [103] etc.

Doesn't this pose a potential problem? What if we need the array keys to be [101], [102], [103] etc.?

For example they keys were to indicate an isbn? What is the best way to handle this?

3 Answers

Thanks for taking the time Luc, but this wasn't what I was asking. I understand how arrays work. I am referring in this lesson to when we pull the information from a database. The database converts the info into an array, but reassigns they array keys to [0],[1,],[2] etc. But earlier in the lesson we were using our own custom defined keys such as [101], [102], [103] etc. What happens to these custom defined keys?

Luc de Brouwer
seal-mask
.a{fill-rule:evenodd;}techdegree
Luc de Brouwer
Full Stack JavaScript Techdegree Student 17,939 Points

I think they still exist. Have you tried using print_r to print out the entire array to see what happens with the values inside those keys?

Leigh Maher
Leigh Maher
21,830 Points

I just added the media_id to the database query and it appears the id's are integers starting from 1 and upwards. My guess is that she'll explain it in the next video but I would say that we are finished with the original id's that we used in the non-database array.