What is the use of an associative array? Why not just make an object and call it a day? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What is the use of an associative array? Why not just make an object and call it a day?

9th Jul 2016, 7:47 PM
Jason
2 Answers
0
I'd like to know too
13th Jul 2016, 4:42 PM
Sergio Zemskov
Sergio Zemskov - avatar
0
Actually you can just use the object, since after you create an array but use it like an associative array its treated the same was like any other object. Why do we still want to initialize an array first? I guess this is some coding standard. Like this you show to someone else that you intent to use the object as a list and not as an object which represents a single thing. As long as your consistent and name your variables in a meaningful way you can do it the way you want. Though it has always been a good idea to follow some of the wide spread guidelines.
8th Jan 2018, 10:07 PM
MarquisBs
MarquisBs - avatar