+ 1
Can anyone give proper explanation of associative arrays in php with an real life example?
Arrays in PHP
2 Antworten
+ 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
+ 1
Thanks