Common Array Functions in php

Source: Internet
Author: User
: This article mainly introduces common array functions in php. For more information about PHP tutorials, see. 1. locate the array:

  1. Bool in_array (mixed needle, array haystack [, bool strict]) to find the specified element;
  2. Array array_keys (arraqy input [, mixed search_value]) an array composed of return key values;
  3. Bool array_key_exists (mixed key, array search) determines whether the key value is the specified key value;
  4. Array array_values (array input) returns the element values in the array;
  5. 2. traverse the array:
  6. Mixed key (array input) returns the key value of the current pointer element;
  7. Mixed reset (array input_array) resets the pointer to the starting position of the array;
  8. Array each (array input_array) returns the array value of the current pointer position;
  9. Mixed current (array input_array) returns the value of the array element at the current pointer position;
  10. Mixed end (array input_array) returns the current pointer pointing to the last element;
  11. Mixed next (array input_array) returns the array element at the next position of the current pointer;
  12. Mixed prev (array input_array) returns the array value located in the previous position of the current pointer;
  13. 3. add and delete array elements:
  14. Int array_push (array & array, mixe var [, mixed...]) to add the specified value to the end of the array;
  15. Mixed array_pop (array & array) returns the last element of the array and resets the array pointer;
  16. Mixed array_shift (array target_array) returns the first element value of the array;
  17. Int array_unshift (array & array, mixed var [, mixed...]) to add the specified element to the starting position
  18. Array array_pad (array input, int pad_size, mixed pad_value) adds the array to the specified length.
  19. 4. sort arrays:
  20. Bool sort/rsort (array & array [, int sort_flags]); ascending and descending;
  21. 5. Merge and split arrays:
  22. Array array_combine (array keys, array values) array merging;
  23. Array array_merge (array array1 [, array array2 [array...]) combines multiple numbers and returns a new array;
  24. Array array_slice (array, int offset [, int length]) extracts the specified length from the specified position of the array and saves it to a new array;
  25. Array explode (string separator, string) is separated and the result is saved;
  26. Array implode (string glue, array pieces) specifies a new character for the element to be connected through a string;
  27. 5. create an array of the specified range:
  28. Array range (mixe low, mixed high [, number step]) to create an array of the specified range;
  29. Array shuffle ($ array) random sorting of elements in the specified array;
  30. Number array_sum (array input_array) sums all elements;

The above describes the common array functions in php, including the content, and hope to help those who are interested in the PHP Tutorial.

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.