Home / PHP Tips Generated By ChatGPT / Sorting an Associative Array by Value in PHP Use asort() to sort an array and maintain index association. Source Code $fruits = ['d' => 'lemon', 'a' => 'orange', 'b' => 'banana', 'c' => 'apple']; asort($fruits); print_r($fruits);