oddball25 Posted February 17, 2011 Share Posted February 17, 2011 Hi I am having trouble using the min() function to find the lowest value within my session arrays. On my site i have the following car values saved into my $car array: $car = array( "itemNumber" => $itemNumber, "Model" => $Model, "EngineSize" => $EngineSize, "Colour" => $Colour, "Value" => $Value, ); I then store each $item array into a $_SESSION['all'] as below: if (isset($_SESSION['all'])) { $_SESSION['all'][$number] = $car; } else { $_SESSION['all'] = array($number => $car); } Now i need to find the lowest Value of all the cars that the user may add. I have been using the min() function to try and do this with the following code but it gives me the error: Wrong parameter count for min()..... $cheapest = min($car['Value']); Am i on the right tracks or is this not possible? If anyone could shed some light on how i can get this to work, would be very much appreciated! Quote Link to comment Share on other sites More sharing options...
oddball25 Posted February 17, 2011 Author Share Posted February 17, 2011 Solved with: $values = array(); foreach ($_SESSION['all'] as $car) { $values[] = $car['value']; } $cheapest = min($values); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.