CS 85  PHP Programming

Arrays

Reference: Programming PHP by Rasmus Lerdorf

Examples: Chapter 5  Arrays

Indexed Versus Associative Arrays

Identifying Elements of an Array

Storing Data in Arrays

Adding Values to the End of an Array

Assigning a Range of Values

Getting the Size of an Array

Padding an Array

Multidimensional Arrays

Extracting Multiple Values

Slicing an Array

Splitting an Array into Chunks

Keys and Values

Checking Whether an Element Exists

Removing and Inserting Elements in an Array

Converting Between Arrays and Variables

Creating Variables from an Array

Creating an Array from Variables

Traversing Arrays

The foreach Construct

The Iterator Functions

Using a for Loop

Calling a Function for Each Array Element

Reducing an Array

Searching for Values

Sorting

Sorting One Array at a Time

Natural-Order Sorting

Sorting Multiple Arrays at Once

Reversing Arrays

Randomizing Order

Acting on Entire Arrays

Calculating the Sum of an Array

Merging Two Arrays

Calculating the Difference Between Two Arrays

Filtering Elements from an Array

Using Arrays

Sets

Stacks

Queues

Last Modified: