PHP array functions

Source: Internet
Author: User

1.array_column to get a column in an array

$arrUsers=Array(      Array(              ' id ' = 1, ' name ' = ' Zhang San ', ' age ' = 25,      ),Array(              ' id ' = 2, ' name ' = ' John Doe ', ' age ' = 23,      ),Array(              ' id ' = 3, ' name ' = ' Harry ', ' age ' = 40,      ),Array(              ' id ' = 4, ' name ' = ' Zhao Liu ', ' age ' = 31,      ),Array(              ' id ' = 5, ' name ' = ' Yellow seven ', ' age ' = 20,      ),  ); Echo' <pre> '; Var_dump(Array_column ($arrUsers,name));Echo' </pre> ';

Output:

Array (5) {  [0]=>  string(6) "Zhang San"  [1]=>  string(6) "John Doe"   [2]=>  string(6) "Harry"  [3]=>  string(6) "Zhao Liu"   [4]=>  string(6) "Yellow Seven"}

2.array_combine () creates an array with the value of an array as the key and the value of the other array as

Header (' content-type:text/html; Charset=utf-8 ');   $a Array (' id ', ' name ', ' phone ')  ; $b=array(' 1 ', ' shenhuidong ', ' 12345 '); $c=array_combine($a$b); Print_r ($c); output: Array ([id] + 1 [name] = = Shenhuidong [phone] + 12345)

3.array_key_exists ($key, $array) determine if the key exists in the array

4.array_keys ($array) returns all the key names in the array

5.array_values ($array) returns all values in the array

6.array_merge ($arr 1, $arr 2) merging one or more arrays

7.array_multisort () sorting multiple or multidimensional arrays

8.array_search ($value, $array) searches the array for the given value and returns the corresponding key name if one exists.

PHP array functions

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.