In this tutorial, you shall learn about PHP array_change_key_case() function which can change the case of all keys in an array, with syntax and examples.

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 of array_values()

The syntax of array_values() function is

</>
Copy
array_values( array )

where

ParameterDescription
array[mandatory] The array from which values has to be extracted.

Function Return Value

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

Examples

1. Get values fromm an 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

</>
Copy
<?php
$array1 = array("a"=>"apple", "b"=>"banana");
$values = array_values($array1);
print_r($array1);
echo "<br>Values array is: <br>";
print_r($values);
?>

Output