Sort array by value alphabetically php

前端 未结 4 1962
我在风中等你
我在风中等你 2020-12-04 01:39

As the title suggests i want to sort an array by value alphabetically in php.

$arr = array(
    \'k\' => \'pig\',
    \'e\' => \'dog\'
)
4条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-04 02:12

    Note that sort() operates on the array in place, so you only need to call

    sort($a);
    doSomething($a);
    

    This will not work;

    $a = sort($a);
    doSomething($a);
    

提交回复
热议问题