In this section I introduce a number of array functions that perhaps donít easily fall into one of the prior sections, but are nonetheless quite useful.
mixed array_rand(array input_array [, int num_entries])
The array_rand() function will return one or more keys found in input_array. If you omit the optional num_entries parameter, only one random value will be returned. If num_entries is set to greater than one, that many keys will be returned. An example follows:
$states = array("Ohio" => "Columbus", "Iowa" => "Des Moines","Arizona" => "Phoenix");
$randomStates = array_rand($states, 2);
Array (  => Arizona  => Ohio ) ===========================================================
array array_chunk(array input_array, int size [, boolean preserve_keys])
The array_chunk() function breaks input_array into a multidimensional array consisting of several smaller arrays consisting of size elements. If the input array canít be evenly divided by size, the last array will consist of fewer than size elements. Enabling the optional parameter preserve_keys will preserve each valueís corresponding key. Omitting or disabling this parameter results in numerical indexing starting from zero for each array. An example follows:
$cards = array("jh","js","jd","jc","qh","qs","qd","qc",
// shuffle the cards
// Use array_chunk() to divide the cards into four equal "hands"
$hands = array_chunk($cards, 4);
This returns the following (your results will vary because of the shuffle):
Array (  => Array (  => jc  => ks  => js  => qd )
 => Array (  => kh  => qh  => jd  => kd )
 => Array (  => jh  => kc  => ac  => as )
 => Array (  => ad  => ah  => qc  => qs ) )============================================================
Arrays play an indispensable role in programming, and are ubiquitous in every imaginable type of application, Web-based or not. The purpose of this chapter was to bring you up to speed regarding many of the PHP functions that will make your programming life much easier as you deal with these arrays.
The next chapter focuses on yet another very important topic: object-oriented programming. This topic has a particularly special role in PHP 5, because the process has been entirely redesigned for this major release.