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 PHP Functions Function Returns and More PHP Variable Functions

Miguel Nunez
Miguel Nunez
3,266 Points

Would you say that a php key is a synonym of php value?

?

1 Answer

Niko Mendo
Niko Mendo
3,077 Points

Well, if you are talking about arrays in PHP then no, they are not.

You can access to any value within the array by easily using the key. You can use an associative array to store an important string information on the key, however there are good methods and practices on how to store data that you can access with less effort.

For example, you could create an array that contains the strings "movieTitle", "director", "year". Then create another array that contains "Star Wars", "George Lucas", 1980.

You have the information of the keys and values in two separate arrays that you can get. If you want, you could use the array_combine() funcion to create the associative array that links the keys to the values.

Sorry, english is not my native language. I hope that answers your question.

Good luck!