Which of the following are true about associative arrays in PHP?

  • Associative arrays use numeric keys to access elements.
  • Associative arrays preserve the order of elements.
  • Associative arrays can have elements of different data types.
  • Associative arrays can only store a single value.
The correct option is 3. Associative arrays in PHP use string or integer keys to access elements, not numeric keys. Unlike indexed arrays, associative arrays do not preserve the order of elements as they are accessed using the keys. Associative arrays can indeed store elements of different data types, allowing for flexible data representation. They are suitable for organizing and accessing data based on meaningful labels or identifiers. Associative arrays can store multiple key-value pairs, making them suitable for representing more complex data structures. Learn more: https://www.php.net/manual/en/language.types.array.php#language.types.array.syntax
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *