This article introduces the usage of the array_values() function of the PHP array operation function. Friends in need can refer to it.
In the php array function, the array_values() function returns all the values in an array and automatically provides a numerical index for the returned array. The form is as follows: array array_values(array array) Example, get the value of each element found in $fruits: <?php //获取数组中各元素的值 //by bbs.it-home.org $fruits["apple"] = "red"; $fruits["banana"] = "yellow"; $fruits["watermelon"]="green"; $values = array_values($fruits); print_r($values); //Array ( [0] => red [1] => yellow [2] => green ) ?> Copy after login Sometimes you need to expand an array or delete a part of the array. PHP provides some functions for expanding and shrinking arrays. These functions provide convenience for programmers who wish to emulate various queue implementations (FIFO, LIFO). As the name suggests, the function names of these functions (push, pop, shift, and unshift) clearly reflect their functions. Tips: A traditional queue is a data structure in which elements are deleted in the same order as elements are added, which is called first-in-first-out, or FIFO. In contrast, a stack is another data structure in which elements are removed in the reverse order in which they were added. This becomes last-in-first-out, or LIFO. |