English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

PHP Basic Tutorial

PHP Advanced Tutorial

PHP & MySQL

PHP Reference Manual

PHP array_values() Function Usage and Example

PHP Array Function Manual

The array_values() function returns all values in the array

Syntax

array_values($array);

Definition and Usage

This function takes input fromarray Returns all values and array Perform numeric indexing.

Return Value

 Returns an index array containing all values.

Parameter

Serial NumberParameters and Description
1

array (required)

It specifies an array.

Online Example

Use array_values to get all values of an array and use numbers starting from 0 as indices

<?php
   $input = array("a"=>"green", "b"=>"brown", "c"=>"blue", "red");
   
   print_r(array_values($input));
?>
Test and see‹/›

Output Result:

Array ( [0] => green [1] => brown [2] => blue [3] => red )

   PHP Array Function Manual