PHP Array Function Summary _ PHP Tutorial

Source: Internet
Author: User
PHP array operation function summary. The most common data structure in PHP is an array. arrays can help us solve a large part of programming problems. In fact, many array operations do not need to be written by ourselves. the system already comes with an array which is the most commonly used data structure in PHP. arrays can help us solve a large part of programming problems. In fact, many array operations do not need to be written by ourselves. the system already comes with related functions. Next we will introduce some functions related to PHP array operations, which you may not have heard.

  1. Search for a specific value in the array. If yes, return TRUE. Otherwise, return FALSE.
  2. boolean in_array(mixed needle,array haystack[,boolean strict])
  3. Find a specified key in the array. If yes, return TRUE. Otherwise, return FALSE.
  4. boolean array_eky_exists(mixed key,array array)
  5. Search for a specific value in the array. If yes, return TRUE. Otherwise, return FALSE.
  6. boolean array_search(mixed needle,array haystack[,boolean strict])
  7. Obtains a new array composed of all the keys in the array.
  8. array array_keys(array array[,mixed search_value])
  9. Obtains a new array composed of all values of the array.
  10. array array_values(array array)
  11. Determine the array size
  12. integer count(array array[,int mode])integer sizeof(array array[,int mode])
  13. Count the occurrence frequency of array elements
  14. array array_count_values(array array)
  15. Deletes repeated values in an array and returns an array consisting of unique values.
  16. array array_unique(array array)
  17. Returns the element order of the array. if the value of preserve_key is TRUE, the order of the key values of the array remains unchanged.
  18. array array_reverse(array array[,boolean preserve_key])
  19. Replace the array key and value
  20. array array_flip(array array)
  21. Sort arrays sequentially. the sort_flags parameter is optional. default behavior.
  22. SORT_NUMBERIC, sorted by numerical value, SORT_REGULAR is useful for sorting integers or floating-point numbers, SORT_STRING is sorted by ASCII value, sort the keys and values of the asort function in the correct order recognized by the audience unchanged void sort (array [, int sort_flags]) void asort (array [, int sort_flags])
  23. Array sorting in reverse order. the sort_flags parameter is optional. default behavior.
  24. SORT_NUMBERIC, sorted by numerical value, SORT_REGULAR is useful for sorting integers or floating-point numbers, SORT_STRING is sorted by ASCII value, sort arsort function key values in the correct order recognized by the nearest person. The order of void rsort (array [, int sort_flags]) void arsort (array [, int sort_flags]) remains unchanged.
  25. Natural sorting of arrays
  26. void natsort(array array)
  27. Case-insensitive natural sorting
  28. void natcasesort(array array)
  29. Sort the key-value pairs in an array
  30. boolean ksort(array array[,int sort_flags])
  31. Sort the key-value pairs in reverse order.
  32. boolean krsort(array array[,int sort_flags])
  33. Sort by user-defined order
  34. void usort(array array,callback function_name)
  35. Merges the arrays to return a Union array. Array_merge overwrites the front, and array_merge_recursive is merged.
  36. Array array_merge (array array1 [array array2…]) // More than one array array_merge_recursive (array array1, array array2 [, array…]) // More than two
  37. Key and value form a new array
  38. array array_combine(array key,array value)
  39. Returns a part of the array, starting from the offset and ending at the offse + length position.
  40. array array_slice(array array, int offset [,int length])
  41. Delete all elements starting from offset to ending with offset + length, and return the deleted elements as arrays.
  42. array array_splice(array, int offset [,int length[,array peplacement]])
  43. Returns the intersection of arrays. The key value is the key value in the first array.
  44. array array_intersect(array array1,array array2[,arrayN……])
  45. The intersection of the array contains the same key value. The key value is the key value of the first array.
  46. array array_intersect_assoc(array array1,array array2[,arrayN……])
  47. Evaluate the difference set of the array. the first array does not have values in other arrays.
  48. array array_diff(array array1,array array2[,arrayN……])
  49. Evaluate the difference set of the array. the first array does not have the same key value in other arrays.
  50. array array_diffassoc(array array1,array array2[,arrayN……])
  51. Returns one or more key values in the array.
  52. mixed array_rand(array array[,int num_entries])
  53. Shuffling function
  54. void shuffle(array input_array)
  55. Summation of values in the array
  56. mixed array_sum(array array);
  57. Splits an array into a multi-dimensional array that contains size elements.
  58. array array_chunk(array array, int size [,boolean preserve_keys])

Bytes. In fact, there are a lot of array operations that we do not need to write, the system already comes with the phase...

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.