Skip to content
Advertisement

Adding an item to an associative array

JavaScript

This is not working as it replaces the value of data. How can I have it add an associative value each loop though? $file_data is an array of data that has a dynamic size.

Advertisement

Answer

I think you want $data[$category] = $question;

Or in case you want an array that maps categories to array of questions:

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement