PHP array functions

Source: Internet
Author: User
in our daily development, we always use some PHP-related functions for processing, which can solve the problem more effectively, so that the problem is simple, so it is necessary to master these functions.

Prev ($ array name)//move the array pointer forward to a position opposite to next ().

Next ()-Points the inner pointer to the next element in the array and outputs it.

Current ()-Returns the value of the present element in the array.

End ()-Points the inner pointer to the last element in the array and outputs

Reset ()-Points the inner pointer to the first element in the array and outputs it.

each ()-Returns the key name and key value of the current element and moves the internal pointer forward.

Array_values ($ array name) takes the values of the array elements in the array to form a new indexed array, which is returned.

Array_keys ($ array name); Extracts the key names from the array to construct a new indexed array, returning

Array_flip ($ array) converts the key name and key value of the array to a new associative array, which is returned.

In_array ($value, $ array name) in the array to query whether $value exists, if present, returns true if there is no return false;

Array_search ($value, $ array name), if value exists in the array, returns the key name, no return is false;

Array_key_exists ($key, $ array name) detects if the key name exists in the array, there is a return of true, there is no return false;

Range ($star, $end); Returns a new index array consisting of an integer group from start to end

Array_reverse ($ array name) reverses the order of the array elements in the array

Array_rand ($ array name, $num) randomly takes out num keys to form a new indexed array to return

Shuffle ($ array name) disrupts the position of the array element values

Array_merge ($arr 1, $arr 2); merging two arrays, if you have the same key name, kill

Array_sum ($ array name) adds the array elements in the array to sum

Array_product ($ array name); Multiply array elements to quadrature

Array-string-related functions

Explode ("delimiter", string) splits the string into delimiters, returning an array.

Implode ("linker", $ array name); concatenate the array elements in the array with a connector, returning a string

Segmentation and padding of arrays

Array_chunk ($ array name, $num) splits the array by num number and returns a two-dimensional array

Array_pad ($ array name, $length, string); When length > count ($ array name), the number of elements is filled with a string.

Array_fill ($start, $length, "string") Start is the starting key name, the number of length array elements,

The Array_shift () function deletes the first element in the array and returns the element that was deleted.

These array functions are often used in our daily development, and in this case, daily development is completely free of problems.

Related content :

A detailed description of PHP array functions

PHP array functions for the editing of associated tables

The definition and usage of PHP array function Array_push ()

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.