<<

. 103
( 132 .)



>>

with the supplied array
array Returns the elements
array_slice(array input,
specified by offset and
int offset [, int length])
length

Continued
618 Part V: Appendixes


TABLE F-3 ARRAY FUNCTIONS (Continued)

Function Return Value Action

array Merges the elements from
array_merge(array arr1, array
passed arrays into one
arr2 [, array ...])
array
array Recursively merges
array_merge_recursive(array
elements from passed
arr1, array arr2 [, array ...])
arrays into one array
array Returns just the keys from
array_keys(array input
the input array, optionally
[, mixed search_value])
only for the specified
search_value

array Returns just the values
array_values(array input)
from the input array
array Returns an array using the
array_count_values(array input)
values of the input array as
keys and their frequency in
input as values
array Returns input as a new
array_reverse(array input
array with the order of the
[, bool preserve keys])
entries reversed
array Returns a copy of the input
array_pad(array input,
array padded with
int pad_size, mixed pad_value)
pad_value to size
pad_size

array Returns an array with the
array_flip(array input)
key <-> value flipped
array Returns an array with all
array_change_key_case(array
string keys rendered in
input [, int case=CASE_LOWER])
lower case (or upper cased)
array Removes duplicate values
array_unique(array input)
from the array
Appendix F: PHP Function Reference 619



Function Return Value Action

array Returns the entries of
array_intersect(array arr1,
arr1 that have values that
array arr2 [, array ...])
are present in all the other
arguments
array Returns the entries of
array_diff(array arr1, array
arr1 that have values that
arr2 [, array ...])
are not present in any of
the other arguments
bool Sorts multiple arrays at
array_multisort(array ar1
once, much as the ORDER
[, SORT_ASC|SORT_DESC
BY clause does in SQL
[, SORT_REGULAR|SORT_NUMERIC|
SORT_STRING]] [, array ar2
[, SORT_ASC|SORT_DESC
[, SORT_REGULAR|SORT_NUMERIC|
SORT_STRING]], ...])

mixed Returns the key/keys for
array_rand(array input
random entry/entries in the
[, int num_req])
array
mixed Returns the sum of the
array_sum(array input)
array entries
mixed Iteratively reduces the
array_reduce(array input,
array to a single value via
mixed callback [, int initial])
the callback
array Filters elements from the
array_filter(array input
array via the callback
[, mixed callback])

array Applies the callback to the
array_map(mixed callback, array
elements in given arrays
input1 [, array input2 ,...])

bool Checks if the given key or
array_key_exists(mixed key,
index exists in the array
array search)

array Splits the array into chunks
array_chunk(array input,
int size [, bool preserve_keys])
620 Part V: Appendixes


TABLE F-4 DATE/TIME FUNCTIONS

Function Return Value Action

int Returns the current Unix
time(void)
timestamp
int Gets the Unix timestamp
Mktime(int hour, int min, int
for a date
sec, int mon, int day, int year)

int Gets the Unix timestamp
gmmktime(int hour, int min, int
for a GMT date
sec, int mon, int day, int year)

string Formats a local time/date
date(string format
[, int timestamp])

string Formats a GMT/UTC
gmdate(string format
date/time
[, int timestamp])

array Returns the results of the
localtime([int timestamp
C-system call localtime
[, bool associative_array]])
as an associative array if
the associative_array
argument is set to 1;
otherwise it is a regular
array
array Gets date/time information
getdate([int timestamp])

bool Returns true if the given
checkdate(int month,
values represent a valid
int day, int year)
date in the Gregorian
calendar
string Formats a local time/date
strftime(string format
according to locale
[, int timestamp])
settings
string Formats a GMT/UCT
gmstrftime(string format
time/date according to
[, int timestamp])
locale settings
int Converts a string
strtotime(string time, int now)
representation of the date
and time to a timestamp
Appendix F: PHP Function Reference 621


TABLE F-5 DIRECTORY FUNCTIONS

Function Return Value Action

mixed Opens a directory and
opendir(string path)
returns a dir_handle
class Returns a directory
dir(string directory)
pseudo-class, with
properties handle and
path, and methods
read(), rewind() and
close()

void Closes the directory
closedir([resource dir_handle])
connection identified by
the dir_handle
bool Changes the root directory
chroot(string directory)

bool Changes the current
chdir(string directory)
directory
mixed Gets the current directory
getcwd(void)

void Rewinds dir_handle
rewinddir([resource dir_handle])
back to the start
string Reads the directory entry
readdir([resource dir_handle])
from dir_handle




TABLE F-6 DNS-RELATED FUNCTIONS

Function Return Value Action

string Gets the Internet host
gethostbyaddr(string ip_address)
name corresponding to
a given IP address
string Gets the IP address
gethostbyname(string hostname)
corresponding to a given
Internet host name
Continued
622 Part V: Appendixes


TABLE F-6 DNS-RELATED FUNCTIONS (Continued)

Function Return Value Action

array Returns a list of IP
gethostbynamel(string hostname)
addresses that a given host
name resolves to
int Checks DNS records
checkdnsrr(string host
corresponding to a given
[, string type])
Internet host name or
IP address
int Gets MX records
getmxrr(string hostname,
corresponding to a given
array mxhosts [, array weight])
Internet host name




TABLE F-7 EXECUTION FUNCTIONS

Function Return Value Action

string Executes an external
exec(string command [, array

<<

. 103
( 132 .)



>>