简体   繁体   中英

How to sort multidimensional array with PHP?

I've an array like below, what I want is to display record having row at the bottom whose "quotes" array is empty.

Array
(
[0] => Array
    (
        [id] => 0
        [regNo] => LHR7171
        [quotes] => Array
            (
            )

    )

[1] => Array
    (
        [id] => 2
        [regNo] => YN09 BYY (9)
        [quotes] => Array
            (
somevalues in array format
            )

    )
uasort(
    $i,
   function($value1, $value2) {
       return count($value2['quotes']) - count($value1['quotes']);
    }
);

And regarding the tags below your question: this has (of course) absolutely nothing to do with SF2 or Twig. This is just plain PHP.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM