Skip to content
Advertisement

Add array data by name php

I’m new to arrays. I’d like to know if you can add data to the array by name. This would be an example of what I want to achieve

example:

JavaScript

result

JavaScript

what I want is to add the data “ibanez” to the array “names” but nevertheless create a new one.

I need it to stay this way. Is there any way to access the data directly by the name “names”?

JavaScript

Advertisement

Answer

You want to use associative arrays. In this case, for example, use the arrow token to associate the guitar names with the “names” key.

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