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 Array_unshift ($item, ' banana ') at the top of the array, Print_r ($item);//Add an array at the end of the array Array_push ($ Item, ' Pineapple ');p rint_r ($item);//delete the first element Array_shift ($item);p rint_r ($item);//delete last element Array_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 a random array of subscripts, 1 for 1 elements of subscript $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 ', ' West ');//Gets the current element, Echo ($username);//Gets the next element echo next ($username);// Resets the current element echo reset ($username); Echo next ($username);//Reverse an echo prev ($username); ><?php//subscript corresponds to the number of repetitions $item =array (' a ' = ' = ' Apple ', ' b ' = ' banana ', ' C ' + ' cantaloupe ', ' d ' and ' = ' apple ');//Gets the number of elements echo sizeof ( $item);p Rint_r (Array_count_values ($item));//Copy the value of key into a variable and extract ($item); Echo $a; >
A pointer to an array in the PHP learning record array