Php array_push () Array Function: pushes one or more units to the end of the array (into the stack)

Source: Internet
Author: User

Copy codeThe Code is as follows: <? Php
/* Function array_push (): pushes one or more units to the end of the array (into the stack)
* 1. Syntax: int array_push (array & array, mixed var [, mixed...])
* 2. Description: Use array as a stack and press the passed variables to the end of array. The length of array increases according to the number of variables in 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 written into the array stack as an array variable. That is, the length of the original array is increased by a unit.
*/

Echo "************************************** ******************************** <br> ";
$ Arr11 = array ('score 1' => 65, 'score 2' => 25, 'score 3' => 87, 'score 4' => 85, 'score 5' => 45, 'score 6' => 66 );
$ Arr22 = array (a, B, c, d, e );
Echo "array arr11 information :";
Echo "<pre> ";
Print_r ($ arr11 );
Echo "</pre> ";
Echo "array arr22 information :";
Echo "<pre> ";
Print_r ($ arr22 );
Echo "</pre> ";
Echo "the number of original elements of array arr1 is:". count ($ arr11). "<br/> ";
$ Num1 = array_push ($ arr11, 66,100 );
Echo "after stack entry, the total number of elements in the array is:". $ num1 ."! In this case, the elements of the array are: <br/> ";
Echo "<pre> ";
Print_r ($ arr11 );
Echo "</pre> ";
$ Num2 = array_push ($ arr11, $ arr22 );
Echo "after the array arr22 is pushed to the array arr11 :";
Echo "after stack entry, the total number of elements in the array is:". $ num2 ."! In this case, the elements of the array are: <br/> ";
Echo "<pre> ";
Print_r ($ arr11 );
Echo "</pre> ";
?>

The running result is 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.