05.05.2013 Views

Programming PHP

Programming PHP

Programming PHP

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Returns a copy of the input array padded to the length specified by size. Any new elements<br />

added to the array have the value of the optional third value. You can add elements to the<br />

beginning of the array by specifying a negative size—in this case, the new size of the array<br />

is the absolute value of the size.<br />

If the array already has the specified number of elements or more, no padding takes place<br />

and an exact copy of the original array is returned.<br />

array_pop<br />

mixed array_pop(array stack)<br />

Removes the last value from the given array and returns it. If the array is empty (or the<br />

argument is not an array), returns NULL.<br />

array_push<br />

int array_push(array array, mixed value1[, ... mixed valueN])<br />

Adds the given values to the end of the array specified in the first argument and returns the<br />

new size of the array. Performs the same function as calling $array[] = $value for each of<br />

the values in the list.<br />

array_rand<br />

mixed array_rand(array array[, int count])<br />

Picks a random element from the given array. The second, optional, parameter can be given<br />

to specify a number of elements to pick and return. If more than one element is returned,<br />

an array of keys is returned, rather than the element’s value.<br />

Before you call array_rand( ), be sure to seed the random-number generator using srand( ).<br />

array_reduce<br />

mixed array_reduce(array array, mixed callback[, int initial])<br />

Returns a value derived by iteratively calling the given callback function with pairs of<br />

values from the array. If the third parameter is supplied, it, along with the first element in<br />

the array, is passed to the callback function for the initial call.<br />

array_reverse<br />

array array_reverse(array array[, bool preserve_keys])<br />

Returns an array containing the same elements as the input array, but whose order is<br />

reversed. If the second parameter is given and is true, the keys for the elements are<br />

preserved; if not, the keys are lost.<br />

This is the Title of the Book, eMatter Edition<br />

Copyright © 2002 O’Reilly & Associates, Inc. All rights reserved.<br />

array_reverse | 381

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!