code

Push is a term used to refer to the addition of a node to a stack, and similar operations.

JavaScript

var length;
var arr1 = ["dog", "cat", "mouse"];

arr1.push(arr1, "gopher");
length = arr1.push("shrew");

alert(length); /* Returns: 5 */
alert(arr1.length); /* Returns: 5 */
alert(arr1); /* Returns: dog,cat,mouse,gopher,shrew */

PHP-JavaScript

PHP-JavaScript is an implementation of the PHP libraries in JavaScript. While the native libraries are recommended both for efficiency and for the sake of using libraries other JavaScript programmers know, the PHP-JavaScript alternative is documented below.

Implementation

function array_push(arr) {
	for (var i = 1; i < arguments.length; i++) {
		arr.push(arguments[i]);
	}
	return arr.length;
}

Example

var arr1 = ["dog", "cat", "mouse"];
var total = array_push(arr1, "gopher", "shrew");

alert(total); /* Returns: 5 */
alert(arr1); /* Returns: dog,cat,mouse,gopher,shrew */

PHP

array_push($arr, $var1, $var2);

or

$arr[] = $var1;
$arr[] = $var2;

Python

def array_push(arr, value)
	return arr.append(value)

Visual basic

function array_push(arr,value)
	redim preserve arr(ubound(arr)+1)
	arr(ubound(arr)) = value
end function