SoFunction
Updated on 2025-03-06

php array_values ​​Returns detailed explanation and example of all values ​​of the array

php array_values

The php array_values ​​function is used to return all values ​​in the array. Note that the function will create an array index for the new array, and the original literal index will not exist. This article explains to you the basic syntax and usage examples of the array_values ​​function.

array_values ​​Return all values ​​in the array

Basic syntax:

array array_values ( array $input )

array_values() Returns all values ​​in the input array and indexes them numerically.

Parameter description:

parameter describe
input Required. Specify array.

Return value:

Returns an index array with all values.

Notice:

All returned new arrays will be indexed using numericals starting at 0.

Example:

<?php
$array = array(
  "php" => "php code",
  "html" => "html code",
  "css" => "css code",
  "js" => "js code",
);
print_r(array_values($array));
?>   

Running results:

Array ( [0] => php code [1] => html code [2] => css code [3] => js code )

Thank you for reading, I hope it can help you. Thank you for your support for this site!