PHP Array Learning (1)

Source: Internet
Author: User
PHP Array Learning Record (1)
Some methods for arrays
$test _arr = Array (' name ' = = ' Test ', 2 = 2, ' color ' = ' red '); Echo ' uses the Var_dump method to output an array: '; Var_dump ($test _arr); Echo '

Output array using the Print_r method: ';p rint_r ($test _arr), if (Is_array ($test _arr)) {echo "

$ test_arr is an array ";} echo "

Array_push Add item in array "; Array_push ($test _arr,array (' good ', ' nice '), ' three ', ' four '); Var_dump ($test _arr); echo"

Array_pop usage "; Array_pop ($test _arr);p rint_r ($test _arr); echo"

Array_shift returns the first element in the array "; $b = Array_shift ($test _arr);p rint_r ($b); echo"

Array_unshift: "; Array_unshift ($test _arr, ' unshift ');p rint_r ($test _arr); echo"

Array_pad: "; $c = Array_pad ($test _arr,-7, ' Xiang ');p rint_r ($c); echo"

In_array: "If (In_array (2, $test _arr)) {echo ' In_array through validate ';} Else{echo ' validate die. ';} echo "

Array_keys: Returns the array key name combined into a set: "; $allmarke = Array_keys ($test _arr); Var_dump ($allmarke);

Ready to be perfected
  • 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.