Home > Backend Development > PHP Tutorial > php array_push() array function: push one or more cells to the end of the array (push)_PHP tutorial

php array_push() array function: push one or more cells to the end of the array (push)_PHP tutorial

WBOY
Release: 2016-07-21 15:26:51
Original
1311 people have browsed it

Copy code The code is as follows:

/*Function array_push(): Push one or more units Push into the end of the array (push into the stack)
* 1. Syntax: int array_push (array &array, mixed var [, mixed ...])
* 2. Description: Treat array as a stack and pass in The variable is pushed to the end of the array. The length of array will increase according to the number of variables pushed onto the stack.
* 3. Notes:
* 3.1. This function returns the total number of new elements in the array
* 3.2. If var is an array, the array is pushed into the array stack as an array variable. That is, the length of the original array is increased by one unit
*/

echo "****************************** **********************************************
";
$arr11=array('Grade 1'=>65,'Grade 2'=>25,'Grade 3'=>87,'Grade 4'=>85,'Grade 5'=> ;45,'score 6'=>66);
$arr22=array(a,b,c,d,e);
echo "Information of array arr11:";
echo "< ;pre>"; <br>print_r($arr11); <br>echo "";
echo "Information of array arr22:";
echo "
"; <br>print_r($arr22); <br>echo "
";
echo "The original number of elements in array arr1 is: ".count($arr11)."
";
$num1=array_push($arr11,12,55,66,100);
echo "After pushing onto the stack, the total number of elements in the array is: ".$num1."! The elements of the array at this time They are:
";
echo "
"; <br>print_r($arr11); <br>echo "
";
$num2=array_push ($arr11,$arr22);
echo "After array arr22 is pushed onto array arr11:";
echo "After being pushed onto the stack, the total number of elements in the array is: ".$num2."! This The elements of the array are:
";
echo "
"; <br>print_r($arr11); <br>echo "
";
?>

The running results are as follows:

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/323845.htmlTechArticleCopy the code as follows: ?php /*Function array_push(): Push one or more cells into the array End (push) * 1. Syntax: int array_push (array lt;br"; $arr11=array('score 1'=...
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template