Php Array


The + operator returns the right-hand array appended to the left-hand array; for keys that exist in both arrays, the elements from the left-hand array will be used, and the matching elements from the right-hand array will be ignored. A callable to run for each element in each array. Null can be passed as a value to callback to perform a zip operation on multiple arrays. If only array is provided, arraymap will return the input array. An array to run through the callback function. Supplementary variable list of array arguments to run through the callback function.

PHP array push: Main Tips

  • PHP array_push() function is used to insert new elements into the end of an array and get the updated number of array elements.
  • You may add as many values as you need.
  • Your added elements will always have numeric keys, even if the array itself has string keys.
  • PHP array push function has been introduced in PHP 4.

array_push() Explained

This function is used to insert elements into the end of an array. Here is a simple example to get you started:

Learn Correct Syntax

Php Array_any

To have PHP array push function executed correctly, you have to follow this syntax:


In the table below, the parameters used in the PHP array push function are explained one by one:

arrayNecessary. Defines an array.
value1Necessary. Defines the value to add.
value2Optional. Defines the next values to add.
Php Array


Look at the code below. You can see an array that contains string keys. Let's see how two new values are added at the end of it using PHP array push function:

PHP array_values() Function

The PHP array_values() function returns an indexed array with all the values from given array.

In this tutorial, we will learn the syntax of array_values() and how to use it to get values from associative arrays and indexed arrays.

Syntax – array_values()

The syntax of array_values() function is


Function Return Value

array_values() returns an indexed array containing all the values of array given as argument to it.

Example 1: Get Values in Array

In this example, we will take an array with two key-value pairs. We will get the values alone form this array using array_values() function.

PHP Program


Please note that the returned array is an indexed array with index starting from 0.

Example 2: Get Values in Indexed Array

In this example, we will take an indexed array with two items. We will get the values alone form this array using array_values() function. The index is dropped and the values alone are picked.

PHP Program



Example 3: Get Values in Array with Default Index

If you provide an array with default index, then the result of array_values() function is also same as the of the given input array. Camera shutter count canon.

Php Array

PHP Program

Php Array Methods



In this PHP Tutorial, we learned how to get all values in an array, using PHP Array array_values() function.