- PHP

Get the Key of the Lowest Value in the PHP array

Use the array_search() and min() functions.

array_search(min($array), $array);

Example:

Find the cheapest product in the array with product names and prices.

<?php

$products = [
    "Phone" => 399,
    "Car" => 20000,
    "Mineral Water" => 2,
    "Headphones" => 99, 
];

echo 'Lowest price: ' . array_search(min($products), $products);

?>

Output: Lowest price: Mineral Water