PHP Version
4+
/** Associative array **/
$assoc = ['name' => 'Alice', 'age' => 25];

// Get a list of all values
$values = array_values($assoc);
var_dump($values);
// Output: array(2) { [0]=> string(5) "Alice" [1]=> int(25) }

/** Indexed array **/
$indexed = ['apple', 'banana', 'cherry'];

// Using array_values() on an indexed array gives the same result
// because it already has consecutive numeric indexes starting from 0
$values_indexed = array_values($indexed);
var_dump($values_indexed);
// Output: array(3) { [0]=> string(5) "apple" [1]=> string(6) "banana" [2]=> string(6) "cherry" }

// Note: array_values() does not modify the original array.
array_values(array $array): array

/** Associative array **/
$array_1 = [
    0 => 100,
    'color' => 'green'
];
print_r(array_values($array_1));
// Output: Array ( [0] => 100 [1] => green )

/** Multidimensional array **/
$array_2 = [
    'color' => ['red', 'green', 'blue'],
    'size' => ['small', 'medium', 'large']
];
print_r(array_values($array_2));
/*
Output:
    Array
    (
        [0] => Array ( [0] => red [1] => green [2] => blue )
        [1] => Array ( [0] => small [1] => medium [2] => large )
    )
*/

/** Empty array **/
$array_3 = [];
print_r(array_values($array_3));
// Output: Array ( )
// Order information
$order1 = [
    'order_id' => 101,
    'customer_name' => 'Alice',
    'total_amount' => 50
];

$order2 = [
    'order_id' => 102,
    'customer_name' => "Bob",
    'total_amount' => 75
];

// More orders...
// Order information
$order1 = [
    'order_id' => 101,
    'customer_name' => 'Alice',
    'total_amount' => 50
];

$order2 = [
    'order_id' => 102,
    'customer_name' => "Bob",
    'total_amount' => 75
];

// Store orders in an array
$orders = array($order1, $order2);

// Calculate the total order amount
$totalAmount = 0;
foreach ($orders as $order) {
    // Extract values using array_values()
    $orderValues = array_values($order);

    // Use the index for the total amount
    $totalAmount += $orderValues[2];
}

// Display the total order amount
echo 'Total Order Amount: $' . number_format($totalAmount); // Output: 'Total Order Amount: $125'
// Create an associative array of members
$members = [
    101 => 'Alice',
    102 => "Bob",
    103 => "Carol"
];

// Print member names while preserving order
$memberNames = array_values($members);

foreach ($memberNames as $name) {
    echo 'Member Name: ' . $name . '<br>';
}

/*
Output:
    Member Name: Alice
    Member Name: Bob
    Member Name: Carol
*/