Common array functions in PHP

Source: Internet
Author: User
1, locate the array:

  1. BOOL In_array (mixed needle,array Haystack[,bool Strict]) finds the specified element;
  2. Array array_keys (arraqy input [, mixed search_value]) returns an array of 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 value of the element in the array;
  5. 2, iterate through 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 position of the currently pointer;
  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 at the previous position of the current pointer;
  13. 3, adding, deleting array elements:
  14. int array_push( array & array, Mixe var [, mixed ...]) Increments 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 ...]) Adds the specified element to the starting position
  18. Array array_pad(array input,int pad_size,mixed pad_value) increments the array to the specified length
  19. 4, sort the array:
  20. BOOL Sort/rsort (array &array[, int sort_flags]); ascending and descending;
  21. 5, merging and splitting of arrays:
  22. Array The merging of Array_combine( array keys, arrays values);
  23. Array array_merge(array array1[,array array2[ Array array...]) Multiple arrays are merged and a new array is returned;
  24. Array array_slice ( array 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 string) is split before the result is saved;
  26. Array implode (string glue,array pieces) specifies the new character in which the element is concatenated via a string;
  27. 5, create an array of the specified range:
  28. Array Range (Mixe Low, mixed high[,number step]) creates an array of the specified range;
  29. Array Shuffle ($array) randomly sorts the elements in the specified array;
  30. Number array_sum (array Input_array) sums all the elements;

The above describes the common array functions in PHP, including the aspects of the content, I hope that the PHP tutorial interested in a friend helpful.

  • 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.