It took me quite a while to understand arrays in PHP, so I thought this might be useful for some people who are new to PHP!
The key thing to remember with an array is that each element in the array has an index, or key, and then the value.
So if you have an array called $forexample then the first three items in that list by default would be referenced with:
$forexample[0];
$forexample[1];
$forexample[2];
... if the values of these were 3, 4, 5 respectively then echoing out those to the screen, e.g. echo "$forexample[0]"; would result in 3 being output to the screen.
There are also associative arrays, this is where the key is not numerical but could be, for instance, $person['last_name'] = "bobbins"; $person['height'] = 200; and so on.
That's the real basics but hopefully it might help someone!
|