PHP Arrays

Posts about arrays in PHP

Finding The First And Last Items In An Array In PHP

Sunday, March 24, 2013 - 13:41

Getting the first or last item from an array in PHP is usually quite easy. If you create an array and then add a bunch of values to it then the array index will increment by 1 for every element you add. This means that in order to get the first element from an array you just reference the default stating position (0). To get the last item in the array the index key will be the length of the array, minus 1. Here is some example code showing this.

Category: 

Using list() With explode() In PHP

Tuesday, September 8, 2009 - 21:42

A simple way to convert a string into a set of variables is through the use of the explode() and list() functions. list() is a language construct (not really a function) that will convert an array into a list of variables. For example, to convert a simple array into a set of variables do the following:

Category: 

PHP Array Of USA States

Thursday, April 23, 2009 - 13:32

Use the following array if you want to print out a list of USA states either as a list, or as a select box.

Category: