-1

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
            )

    )
BentCoder
  • 10,692
  • 17
  • 82
  • 143
Umair Malik
  • 1,195
  • 3
  • 20
  • 50
  • possible duplicate of [Reference: all basic ways to sort arrays and data in PHP](http://stackoverflow.com/questions/17364127/reference-all-basic-ways-to-sort-arrays-and-data-in-php) – deceze Jun 19 '15 at 07:45

1 Answers1

1
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.

BlueM
  • 3,157
  • 16
  • 30
  • I tried this but it didn't sorted array, where I'm making mistake. uasort( $finalResult, function($finalResult, $finalResult) { return count($finalResult['quotes']) - count($finalResult['quotes']); } ); – Umair Malik Jun 19 '15 at 06:03
  • 1
    How do you expect that to work when you use the same variable name for both function arguments? – BlueM Jun 19 '15 at 06:16
  • ok my mistake, i changed variable, its still not sorting like i need uasort( $finalResult, function($value1, $value2) { return count($value2['quotes']) - count($value1['quotes']); } ); – Umair Malik Jun 19 '15 at 06:22
  • @Umair So what does it do? What result do you get? If you have code which isn't working, edit your question, add that code, clarify what it does and what it should do instead. – deceze Jun 19 '15 at 07:47