PHP array_push () array function: To push one or more cells into the end of an array (into stacks) _php base

Source: Internet
Author: User
Tags mixed
Copy Code code as follows:

<?php
/* Function Array_push (): Pressing one or more cells into the end of the array (on stack)
* 1, Syntax: int array_push (array &array, mixed var [, mixed ...])
* 2, Description: The array as a stack, and the incoming variable pressed into the end of the array. The length of the array increases according to the number of stack variables.
* 3, the attention matters:
* 3.1, this function returns the total number of new elements of the array
* 3.2, such as Var is an array, the array is used as a variable into the stack into the array stack, that is, the length of the original array is to add a cell
*/

echo "***********************************************************************<br>";
$arr 11=array (' score 1 ' =>65, ' score 2 ' =>25, ' score 3 ' =>87, ' score 4 ' =>85, ' score 5 ' =>45, ' score 6 ' =>66);
$arr 22=array (a,b,c,d,e);
echo "Array arr11 information:";
echo "<pre>";
Print_r ($arr 11);
echo "</pre>";
echo "Array arr22 information:";
echo "<pre>";
Print_r ($arr 22);
echo "</pre>";
echo "Array arr1 the number of original elements:". Count ($arr 11). <br/> ";
$num 1=array_push ($arr 11,12,55,66,100);
echo "After the stack, the total number of elements of the array is:". $num 1. "! At this time the elements of the array are: <br/> ";
echo "<pre>";
Print_r ($arr 11);
echo "</pre>";
$num 2=array_push ($arr, $arr 22);
echo "Array arr22 into stack to Arr11 after array:";
echo "After the stack, the total number of elements of the array is:". $num 2. "! At this time the elements of the array are: <br/> ";
echo "<pre>";
Print_r ($arr 11);
echo "</pre>";
?>

The results of the operation are as follows:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.