php sort array by value length

Solutions on MaxInterview for php sort array by value length by the best coders in the world

we are a community of more than 2 million smartest coders
registration for
employee referral programs
are now open
get referred to google, amazon, flipkart and more
register now
  
showing results for - "php sort array by value length"
Hannah
20 Sep 2019
1function sortByLength($a,$b){
2    return strlen($b)-strlen($a);
3}
4usort($array,'sortByLength');