w3resource

PHP: array_values() function

PHP: Return all the values of an array

The array_values() function is used to fetch all the values from an array. The function indexes the array numerically.

Version:

(PHP 4 and above)

Syntax:

array_values(array1)

Parameter:

Name Description Required /
Optional
Type
array1 Specifies the name of the array. Required Array

Return value:

Numerically indexed array of values of array1.

Value Type: Array

Example:

<?php
$fruits_list = array('Orange',  'Apple','Banana', 'Cherry');
print_r(array_values($fruits_list));
?>

Output:

Array ( [0] => Orange [1] => Apple [2] => Banana [3] => Cherry ) 

Pictorial Presentation:

php function reference: array_values() function

View the example in the browser

Practice here online :

See also

PHP Function Reference

Previous: array_unshift
Next: array_walk_ recursive



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://www.w3resource.com/php/function-reference/array_values.php