Home > php教程 > php手册 > PHP function

PHP function

WBOY
Release: 2016-08-22 10:14:28
Original
977 people have browsed it
The difference between the array_merge function and the addition of two arrays
 The array_merge function, when the same index array appears, will merge the index arrays in the two arrays, and add them up with the maximum index value of the first array. If it is an associative array, the value of the subsequent array will overwrite the previous one. Value, for addition, regardless of the index or associative array that appears first, the former is used as the value, and the latter is discarded
array_chunk function
  To cut the array, the first parameter is the array to be cut, the second parameter is the number of elements in each array after cutting, and the third parameter is whether the index of each divided array uses the index name of the original array. , the default is not used
next function
 Returns the value of the next element of the current array element, moves the pointer backward one position, returns false if it does not exist
prev function
 Returns the previous element of the current element and moves the pointer forward one position. Returns true if it does not exist
end function
 Return the value of the last element of the array
current function
 Return the current element of the array without moving the position
sort function
  Sort the values ​​of the array elements in forward order, return true if successful, false if failed. The first parameter is the array to be sorted, and the second parameter is the sorting rule. This function will delete all the original elements of the sorted array. Index value, add new index value after sorting
rsort function
  Sort the values ​​of the array elements in reverse order, returning true if successful and false if failed. The first parameter is the array to be sorted, and the second parameter is the sorting rule. This function will delete all original indexes of the sorted array. value, add new index value after sorting
asort function
  Sort the values ​​of the array elements in forward order and save the index relationship. Return true if successful, false if failed. The first parameter is the array to be sorted, and the second parameter is the sorting rule. The function will maintain the original There is a corresponding relationship between key and value
ksort function
  Sort the keys of the array elements in forward order, return true if successful, false if failed. The first parameter is the array to be sorted, and the second parameter is the sorting rule. This function will maintain the original key-value correspondence. Relationship
shuffle function
Randomly sort the array elements, delete the original key-value relationship, return true if successful, false if unsuccessful
array_reverse function
Sort the array elements in the reverse direction of the original order. The second parameter is the sorted array. If the second parameter is set to true, the original relationship will be maintained after sorting. The default is false
reset function
 Reset an array and move the internal pointer in the array to the cell where the first element of the array is located. If the data is empty, return false
list function
 Assign the elements of the array to variables, and the array is an index array
range function
 Quickly create an array within a specified range. The first parameter is the start value, the second parameter is the end value, and the third parameter is the span. The default is one
array_push function
  Push one or more elements into the end of the array. Successful execution returns the number of units pushed into the array
array_pop function
 Pop the last element of the array, return the last unit of the array, and reduce the length of the array by one. If the array is empty or not an array, return null. After use, the array pointer will point to the first array unit
array_change_key_case function
 Replace all case of strings as array indexes, the first parameter is the array, and the second parameter specifies whether to use uppercase or lowercase
array_intersect function
To calculate the intersection of arrays, there can be multiple parameters, and the key-value correspondence remains unchanged
array_flip function
 Exchange index and value
array_fill function
Set some or all elements in the array to a value. The first parameter is the starting index of the element to be filled, the second parameter is the number of filling, and the third parameter is the value of the filled element
count function
 Count the number of elements in the array
array_count_values ​​function
 Count the number of times each value occurs in the array
array_key_exists function
 Check whether the given index exists in the array, return true if it exists, otherwise return false
array_keys function
  Get all the index names in the array. The first parameter is the array itself. The second parameter is the key value to be selected. The default is all. You can specify a key value to search. The third parameter is used to perform congruence. Compare
array_map function
Apply the callback function to the given array
in_array function
Determine whether a certain value exists in the array. If it exists, it returns true, if not, it returns false. The first parameter is the value you want to find, the second parameter is the array, and the third parameter is used for congruent comparison
key function
 Get the key name of the element pointed to by the current pointer from the associative array
strcmp function
Compare two strings, if str1 waits for str2, return 0, if str1 is less than str2, return -1, if str1 is greater than str2, return a number greater than 0
str_replace function
 Replace all the $search part in str in the string with the string $replace, and return the replaced string. The first parameter is the data to be replaced, the second parameter is the value to be replaced, and the third parameter is the value to be replaced. The first parameter is the string to be operated on, the fourth parameter is the number of substitutions, and when the first and second parameters are arrays, a corresponding relationship is formed
substr_replace function
 The first parameter is the string to be processed, the second parameter is the string to be replaced, and the third parameter is the starting position of the string to replace. If start is a positive number, the replacement will be from the start position of the string. start. ,If start is a negative number, the replacement will start from the penultimate start position of string. The third parameter is the replacement length. If this parameter is set and is a positive number, it indicates the length of the replaced substring in string. If set to a negative number, it represents the number of characters from the end of string to the end of the substring to be replaced. If this parameter is not provided, it defaults to strlen( string ) (the length of the string). Of course, if length is 0, then the function of this function is to insert replacement into the start position of string.
sprintf function
 Format a string. The first parameter is the format to be converted, usually starting with % and ending with the characters being converted. The second parameter is the data to be formatted
substr function
 Get a substring in a string. The first parameter is the string to be processed, the second parameter is the starting position, and the third parameter is the length to be intercepted
rtrim function
 Delete the blank characters (or other specified characters) at the end of the string. The first parameter is the string to be processed, and the second parameter is the character you specify. If not specified, it will be the default
ltrim function
 Delete the blank characters (or other specified characters) at the beginning of the string. The first parameter is the string to be processed, and the second parameter is the character you specify. If not specified, it will be the default
trim function
 Remove whitespace characters (or other specified characters) at the beginning and end of the string
strlen function
 Get the length of a string
mb_strlen function
 Get the length of a string, the first parameter is the string to get the length, the second parameter is the character set to be specified
strtoupper function
Convert all letters in the string to uppercase letters
strtolower function
Convert all letters in the string to lowercase letters
str_repeat function
Used to repeatedly generate a string, the first parameter is the string to be repeatedly generated, and the second parameter is the number of times to be repeated
str_split function
  Split the string into an array. The first parameter is the string to be processed, and the second parameter is the length of the cutting
file_put_contents function
 The first parameter is the path to the file to be written, the second parameter is the content to be written, it will be automatically created if the file to be written does not exist, and the default is replacement writing. When the third parameter is FILE_APPEND, it is expressed as Append writing, the return value is the number of bytes written.
file_get_contents function
Get the file content of the specified path. It is not suitable to be used when the file read is too large. The return value is the obtained content
fopen function
 The first parameter is the path of the file to be opened, and the second parameter is the method of opening the file: r, w (the file will be automatically created if it does not exist, and the file content will be cleared), a, x (the file will not be automatically opened if it does not exist). Create, the file content will be cleared), r+, w+, a+, x+, the return value is the file resource
fwrite function
 The first parameter is the open file resource, the second parameter is the string content of the read length, the size is bytes, the maximum is 8192 bytes
fgets
 The first parameter is the file resource, and the second parameter is to read a string of specified length,
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template