Home Web application programming PHP programming PHP syntax: create an associative array

PHP syntax: create an associative array

An associative array can use non-numeric index values and are useful because they can be iterated over sequentially and values can be extracted individually by index. Database select results can be returned as associative arrays in which the column names become indicies.

The following code creates an associative array of the first few US states and their capitals. The state name is the index and the capital is the value.

"Arkansas"=>"Little Rock",



Please enter your comment!
Please enter your name here

error: Content is protected !!