PHP and MySQL Web development notes--the 3rd chapter uses arrays

Source: Internet
Author: User
Tags php and mysql
you can use = to copy an array into another array.

Range (): Used to generate an arithmetic progression array.

$arr [0]= "Hello";//create an array of length 1, equivalent to $arr = Array ("0" = "Hello");

$arr [1]= "World";

$arr 2 = array ("Hello", "World");//equivalent to the above two lines of code

foreach ( $arr as $now )//foreach Loop

{

echo $now. "
";

}

foreach ( $arr as $key + $value )

{

echo $key. ":" $value. "
";

}

reset ($arr);//reset pointer

//each function

while ($ Element=each ($arr))

{

echo $element [' key ']. ': ' $element [' value ']. " 1
";

}

//Use list for loop

reset ($arr);

while (list ($key, $v) =each ($arr))

{

echo $key. ":" $v. "
";

}

$arr 1+ $arr 2: Add the latter element to the back of the former, and key will not be added or overwritten.

Array sorting:

Sort (), Rsort (): Ascending, descending

Asort (), Arsort (): Sorting values

Ksort (), Krsort (): Key sort

Usort (), Uasort (), Uksort (): Custom comparison rules, custom comparison functions required

Other operations of the array:

Current (): Returns the element that is currently pointer, alias POS ()

Reset (), End (): pointer pointing to First, tail

Next (), prev (): Remove one/previous element

Shuffle (): random element that modifies the original array

Array_reverse (): Array in reverse order, the original array does not change

Array_work (): callback processing for each element in the array using a user-defined function

Count (), sizeof (): Calculates the array length

Array_count_values (): Statistical frequency of values

Extract (): Converts an array to a scalar form

The above describes the PHP and MySQL Web development notes-The 3rd chapter uses arrays, including aspects of the content, I hope to be interested in PHP tutorial friends helpful.

  • Related Article

    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.