+ 1

Can anyone give proper explanation of associative arrays in php with an real life example?

Arrays in PHP

11th May 2019, 4:29 PM
Avijit Bakshi
Avijit Bakshi - avatar
2 Respostas
+ 1
If you do array("foo", "bar", "hello", "world"); you get an indexed array ( 0 => "foo", 1 => "bar", 2 => "hello", 3 => "world" ) The values are assigned integer indexes from 0 to length - 1. You can do this though: array("first" => "John", "last" => "Doe", "age" => 34) Here you have associated indexes to the values yourself. So in the first example $array[0] outputs foo In the 2nd example $array['first'] outputs John
12th May 2019, 3:23 AM
Adam
Adam - avatar
+ 1
Thanks
12th May 2019, 2:57 PM
Avijit Bakshi
Avijit Bakshi - avatar