PHPArray learning Notes (1)

Source: Internet
Author: User
PHPArray learning records (1) some methods about arrays $ test_arr = array ('name' = & gt; 'test', 2 = & gt; 2, 'color' = & gt; "red"); echo 'Learning records using the var_dump method PHP Array (1)
Array methods
$ Test_arr = array ('name' => 'test', 2 => 2, 'color' => "red"); echo 'use the var_dump method to output the array :'; var_dump ($ test_arr); echo'

Use the print_r method to output an array: '; print_r ($ test_arr); if (is_array ($ test_arr) {echo"

$ Test_arr is an array ";} echo"

Array_push add a project to the array "; array_push ($ test_arr, array ('good ', 'Nice'), 'Three ', 'Four'); var_dump ($ test_arr); echo"

Array_pop usage "; array_pop ($ test_arr); print_r ($ test_arr); echo"

Array_shift returns the first element in the array "; $ B = array_shift ($ test_arr); print_r ($ B); echo"

Array_unshift: "; array_unshift ($ test_arr, 'unshift '); print_r ($ test_arr); echo"

Array_pad: "; $ c = array_pad ($ test_arr,-7, 'Xiang '); print_r ($ c); echo"

In_array: "; if (in_array (2, $ test_arr) {echo 'in _ array through validate';} else {echo 'validate die. ';} echo"

Array_keys: returns an array key name combined into a set: "; $ allmarke = array_keys ($ test_arr); var_dump ($ allmarke );

To be improved

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.