Tải bản đầy đủ (.pdf) (5 trang)

PHP Developer''''s Dictionary- P26 docx

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (360.72 KB, 5 trang )

PHP Developer’s Dictionary
IT-SC book
125
The
list()
language construct is used to assign a list of variables in one operation.
The construct
list()
is commonly used to assign multiple return values of a function
to variables.
next()
Syntax

mixed next(array array)


Description
The
next()
function advances the internal pointer by one and returns the element
located at this new location. If there are no more elements in array
to advance to,
the function returns false. Note that this function also returns false if the value of the
element at this location is empty.
pos()
Syntax

mixed pos(array array)


Description


The
pos()
function is an alias to the
current()
function. The
current()
function
returns the element in array that is currently being pointed to by the internal
pointer. Every array has this internal pointer, which is initialized to point to the first
element inserted into the array. If the internal pointer points beyond the element
list, the function returns false.
prev()
Syntax

mixed prev(array array)


Description
The
prev()
function rewinds the internal array pointer by one and returns the
element at that location. If there are no previous elements, the function returns
PHP Developer’s Dictionary
IT-SC book
126
false. Note that this function also returns false if the value of the element at this
location is empty.
range()
Syntax


array range(int low, int high)


Description
The
range()
function, which was added in PHP 3.0.8 and PHP 4.0b4, returns an
array of integers from low
to high
.

$array1 = range(1,4);//returns (1,2,3,4)


reset()
Syntax

mixed reset(array array)


Description
The
reset()
function moves the internal array pointer to the first element in array
and returns the value of the first element.
rsort()
Syntax

void rsort(array array)



Description
The
rsort()
function sorts the
array
in reverse order (highest to lowest).
shuffle()
PHP Developer’s Dictionary
IT-SC book
127
Syntax

void shuffle(array array)


Description
The
shuffle()
function, which was added in PHP 3.0.8 and PHP 4.0b4, randomizes
the order of the elements in array .
sizeof()
Syntax

int sizeof(array array)


Description
The
sizeof()

function returns the number of elements in the array . Empty
elements are included in the count. This function is similar to
count()
, but is used
specifically for arrays.

$array1 = array (1,2,3,4,5,"pos"=>"",);
echo sizeof ($array1);//displays 6


sort()
Syntax

void sort(array array)


Description
The
sort( )
function orders the elements of array . The resulting array is sorted
from lowest to highest.
uasort()
Syntax

PHP Developer’s Dictionary
IT-SC book
128
void uasort(array array, function cmp_function)



Description
The uasort() function, which was added in PHP 3.0.4 and PHP 4.0, sorts the array
based on a user-defined comparison function. The array indices maintain their
relation to the array elements with which they are associated.
uksort()
Syntax

void uksort(array array, function cmp_function)


Description
The
uksort()
function , which was added in PHP 3.0.4 and PHP 4.0, sorts the array
by keys using a user-defined comparison function.
usort()
Syntax

void usort(array array, function cmp_function)


Description
The usort() function, which was added in PHP 3.0.3 and PHP 4.0, sorts the array
by values using a user-defined comparison function.
Dynamic Loading
Loading additional libraries at runt ime can extend the functionality of PHP. After the
external libraries have been loaded, you can call functions from this library as though
they were part of PHP.
dl()
Syntax


int dl(string library)
PHP Developer’s Dictionary
IT-SC book
129


Description
The
dl()
function loads the library
, which is a PHP extension. The library
should
be placed in the directory specified by the extension_dir directive.
Hash()
PHP offers many hashing options through the use of the mhash library. To utilize
these functions, you must download the library from /> and
then compile PHP with the
with-mhash
option to enable it. The hashing routines
include SHA1, GOST, HAVAL, MD5, RIPEMD160, TIGER, and CRC32 checksums.
mhash_get_hash_name()
Syntax

string mhash_get_hash_name(int hash)


Description
The
mhash_get_hash_name()

function, which was added in PHP 3.0.9 and PH P 4.0,
returns the name of the hash associated with hash , which represents a hash ID. If
no hash name corresponds to the hash ID, the function returns false.
mhash_get_block_size()
Syntax

int mhash_get_block_size(int hash)


Description
The
mhash_get_block_size()
function, which was added in PHP 3.0.9 and PHP 4.0,
returns the block size for a given hash
.
mhash_count()
Syntax

int mhash_count(void )

×