PHP array functions (1)

Source: Internet
Author: User
Tags explode prev

quickly create an array
    1. Range () function
      • Format: Array range (mixed start,mixed end) to quickly create a numeric array or a character array from the start to end range.
    1. Explode () function
      • Format: Array explode (string separator,string str), using the specified string delimiter separator to split the string str, place the split string in the array, and return the array.
    1. Array_combine () function
      • Format: Array array_combine (array Keys,array values), creates a new array, uses the value of the array keys as the "key" of the new array, and the value of the array values as the "value" of the new array.
    1. Array_fill () function
      • Format: array array_fill (int start_key,int length,mixed value), creates an array, and adds a length array element for the arrays, and the "key" of the array element increments from the Start_key. Values for each array element are value.
    1. Array_pad () function
      • Format: Array array_pad (array arr,int pad_size,mixed pad_value), returns a copy of the array arr, and fills it with Pad_value to a specified length of pad_size.
        • Note: If Pad_size is positive, the array is filled to the right, and if negative, it is filled from the left. If the absolute value of the pad_size is less than or equal to the length of the arr array, there is no padding.
Array Statistics function
    1. Count () function < alias: sizeof () function >
      • Format: int count (array arr [, int mode]), counts and calculates the number of elements in the array arr.
        • If ARR is a multidimensional array, the value of the mode parameter can be set to constant count_recursive (or integer 1), and the number of all elements in the multidimensional array arr is recursively computed; The default value of mode is 0.
    1. Max () function
      • Format: Mixed max (array arr [, array ...]), statistics and calculates the maximum value of an array of elements in arr.
    1. Min () function
      • Format: mixed min (array arr [, array ...]), statistics and calculates the minimum value of an array of elements in arr.
    1. Array_sum () function
      • Format: Number array_sum (array arr), which counts and computes the array of all element values in arr, and returns an integer or floating point.
    1. Array_product () function
      • Format: Number array_product (array arr), which counts and computes the product of the values of all elements in an array of arr, which returns an integer or floating-point value.
    1. Array_count_values () function
      • Format: Array array_count_values (array arr), which counts and calculates the number of occurrences of the values of all elements in arr.
array pointer functions
    1. Key () function
      • Format: Mixed key (array &arr), returns the "key" name of the element referred to in the "current pointer" in arr.
    1. Current () Functions < aliases: POS () functions >
      • Format: Mixed current (array &arr), returns the "value" of the element referred to in Arr in the "present pointer".
    1. Next () function
      • Format: Mixed next (array &arr), move the array arr "current pointer" (current) to point to the next element of the array arr, and return the "value" of the element referred to by current pointer.
    1. End () function
      • Format: Mixed end (array &arr), move the array arr "current pointer" (current) to point to the last element of the array arr, and then return the "value" of the element referred to by current pointer.
    1. Prev () function
      • Format: Mixed prev (array &arr), move the array arr "current pointer" (current), which points to an array of ARR elements, and then returns the "value" of the element referred to by current pointer.
    1. Reset () function
      • Format: Mixed reset (array &arr), move the array arr "current pointer" (current) to point to the first element of the array arr, and then return the "value" of the element referred to by current pointer.
    1. each () function
      • Format: Array each (array &arr), returning the element (including "key" and "value") referred to in the current pointer as an array, moving the array, arr "current", so that the current pointer Points to the array of arr next element.
        • Description: The function returns an array of 4 elements ("Key-value pairs"), 0, 1, key, and value, respectively;
          The value of the element with key name 0 and key is the key name of the element referred to in arr "Current pointer";
          The value of the element with the key Name 1 and value is the element value that Arr refers to as current pointer.
Key Value
0 Current-key
1 Current-value
Key Current-key
Value Current-value

PHP array functions (1)

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.