Fastest Web Hosting

retrive all maximum value from array using php

0 votes
asked Jun 29 in PHP by rohit (2,750 points)

I need to get all maximum values from array using php,for example array like below,

$arr = array('a'=>10,'b'=>20,'c'=>5,'d'=>20);

I used below code,

$key = array_search(max($arr), $arr);

but i get only 'b',I need to get both 'b' and 'd', Highest all values keys i needed, Anyhelp appreciated.

1 Answer

0 votes
answered Jun 29 by Manoj insa

You Used wrong param , try like below code

$arr = array('a'=>10,'b'=>20,'c'=>5,'d'=>20);
$key = array_keys($arr, max($arr));

Job Board

TechnicalSharp is a technical community of developers where they are sharing their knowledge and solutions and against it they are getting the score point which help them to make profile strong which is under eyes on MNC's