Home >Backend Development >PHP Tutorial >'php and mysql web development' notes - Chapter 3 Using arrays

'php and mysql web development' notes - Chapter 3 Using arrays

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-07-29 09:14:281214browse

You can use = to copy an array into another array.

range(): used to generate an arithmetic sequence array.

asort(), arsort(): value sorting

$arr[0]=”hello”;//Directly create an array with a length of 1, which is equivalent to $arr = array(“0”=>”hello”);

$arr[1]=”world”;

$arr2 = array(“hello”,”world”);//Equivalent to the above two lines of code

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

{

             echo $now."
";

}

foreach($arr as $key=& gt;$ value)

{

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

}

reset($arr);//Reset pointer

//each function

while($element=each($arr))

{

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

}

//Use list to loop

reset($arr);

while(list($key . $arr1+$arr2: Add the latter element to the back of the former. The same key will not be added or overwritten.

Array sorting:

sort(), rsort(): ascending order, descending order

ksort(), krsort( ): Key sorting

usort(), uasort(), uksort(): Custom comparison rules, custom comparison functions are required

Other operations on arrays:

current(): Return the current pointer element, alias pos()

reset(), end(): pointer points to the beginning and end

next(), prev(): remove the next/previous element

shuffle() : Random elements, will modify the original array

                                                    use using a user’s own function ’ s ‐ ‐     ‐   ‐ ‐ ‐ being in reverse order,

) Count (), sizeof (): Calculate array length

Array_Count_values ​​(): Statistically frequency of value

Extract ()

The above has introduced the notes of "php and mysql web development" - Chapter 3 using arrays, including aspects of the content. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:php learning 01Next article:php learning 01