Unshift add an element to the array header, push adds an element to the end of the array, shift deletes the first element of the array, and the pop deletes the last element of the array:
<?php $item=array ('Apple');//add an element to the front of the arrayArray_unshift ($item,'Banana'); Print_r ($item);//add an array at the end of the arrayArray_push ($item,'Pineapple');p Rint_r ($item);//Delete First elementArray_shift ($item);p rint_r ($item);//Delete last elementArray_pop ($item);p rint_r ($item);?>
Array_rand randomly removes the subscript for the array:
<?php $item=array ('Apple','Banana','Pineapple');//use a variable to receive the subscript of the random array, and 1 to take the subscript of 1 elements$a =array_rand ($item,1); Echo $item [$a];? ><?php $item=array ('Apple','Banana','Pineapple'); $a=array_rand ($item,2), Echo $item [$a [0]];echo $item [$a [1]];?>
Current fetch element generally refers to the first element next gets the element of the current next bit reset re-acquires the element from the first start prev backwards a array_count_values (); Number of repetitions of the value of a statistic array extract () Assign a value to a string key after it has been changed to a variable.
<?php $username=array ('Ronaldo','Lionel Messi','Sai Luo');//gets the current elementEcho current ($username);//gets the next elementEcho Next ($username);//Resets the current elementecho Reset ($username); Echo next ($username);//Backwards OneEcho prev ($username);? ><?PHP//number of repetitions of the subscript corresponding value$item =array ('a'='Apple','b'='Banana','C'='Hami Melon','D'='Apple');//gets the number of elementsEchosizeof($item);p Rint_r (Array_count_values ($item));//change the value of key to a variable and copy it to him.extract ($item); echo $a;?>
A pointer to an array in the PHP learning record array