php 5 array functions
Post on 14-Feb-2018
231 Views
Preview:
TRANSCRIPT
7/23/2019 PHP 5 Array Functions
http://slidepdf.com/reader/full/php-5-array-functions 1/2
PHP 5 Array Functions
Function Description
array() Creates an array
array_chunk() Splits an array into chunks of arrays
array_combine() Creates an array by using the elements from one "keys" array an one
"!alues" array
array_iff() Compare arrays an returns the ifferences (compare !alues only)array_fill() Fills an array #ith !alues
array_fill_keys() Fills an array #ith !alues specifying keys
array_intersect() Compare arrays an returns the matches (compare !alues only)
array_intersect_key() Compare arrays an returns the matches (compare keys only)
array_key_e$ists() Checks if the specifie key e$ists in the array
array_keys() %eturns all the keys of an array
array_merge() &erges one or more arrays into one array
array_merge_recursi!e() &erges one or more arrays into one array recursi!ely
array_pop() 'eletes the last element of an array
array_prouct() Calculates the prouct of the !alues in an array
array_push() nserts one or more elements to the en of an array
array_ran() %eturns one or more ranom keys from an array
array_replace() %eplaces the !alues of the first array #ith the !alues from follo#ing
arrays
array_replace_recursi!e() %eplaces the !alues of the first array #ith the !alues from follo#ing
arrays recursi!ely
array_re!erse() %eturns an array in the re!erse orer
array_search() Searches an array for a gi!en !alue an returns the key
array_shift() %emo!es the first element from an array an returns the !alue of the
remo!e element
array_slice() %eturns selecte parts of an array
array_splice() %emo!es an replaces specifie elements of an array
array_sum() %eturns the sum of the !alues in an arrayarray_uniue() %emo!es uplicate !alues from an array
array_!alues() %eturns all the !alues of an array
arsort() Sorts an associati!e array in escening orer accoring to the !alue
asort() Sorts an associati!e array in ascening orer accoring to the !alue
count() %eturns the number of elements in an array
current() %eturns the current element in an array
ne$t() A!ance the internal array pointer of an array
reset() Sets the internal pointer of an array to its first element
sort() Sorts an ine$e array in ascening orer
PHP 5 String Functions
*he PHP string functions are part of the PHP core+ ,o installation is reuire to use these
functions+
7/23/2019 PHP 5 Array Functions
http://slidepdf.com/reader/full/php-5-array-functions 2/2
Function Description
str_ireplace() %eplaces some characters in a string (case-insensiti!e)
str_pa() Pas a string to a ne# length
str_repeat() %epeats a string a specifie number of times
str_replace() %eplaces some characters in a string (case-sensiti!e)
str_split() Splits a string into an array
strcmp() Compares t#o strings (case-sensiti!e)
stristr() Fins the first occurrence of a string insie another string (case-
insensiti!e)
strlen() %eturns the length of a string
strpbrk() Searches a string for any of a set of characters
strpos() %eturns the position of the first occurrence of a string insie another
string (case-sensiti!e)
strrchr() Fins the last occurrence of a string insie another string
strre!() %e!erses a string
strripos() Fins the position of the last occurrence of a string insie another
string (case-insensiti!e)
strrpos() Fins the position of the last occurrence of a string insie another
string (case-sensiti!e)strspn() %eturns the number of characters foun in a string that contains only
characters from a specifie charlist
strstr() Fins the first occurrence of a string insie another string (case-
sensiti!e)
strtok() Splits a string into smaller strings
strtolo#er() Con!erts a string to lo#ercase letters
strtoupper() Con!erts a string to uppercase letters
substr() %eturns a part of a string
substr_count() Counts the number of times a substring occurs in a string
substr_replace() %eplaces a part of a string #ith another string
trim() %emo!es #hitespace or other characters from both sies of a string
top related