deepu07
243
5
Laravel

sorting multidimensional array by one value

Posted 4 months ago by deepu07

Hi Guys, My Api result is like this. Here I want to display students orderBy('start_year') in result. How can I achieve that. Any help that would be appreciated. Thanks!

  324 => array:2 [
    "subjects" => array:2 [
      0 => array:7 [
        "id" => "4"
        "name" => "abc"
        "type" => "Arts"
      ]
      1 => array:7 [
        "id" => "7"
        "name" => "ghi"
        "type" => "Music"
      ]
    ]
    "students" => array:35 [
      0 => array:11 [
        "course_id" => "19"
        "subject_number" => "30"
        "subject_name" => "Season 30"
        "start_year" => "2016"
        "end_year" => "2009"
      ]
      1 => array:11 [
        "course_id" => "196"
        "subject_number" => "31"
        "subject_name" => "Season 31"
        "start_year" => "2007"
        "end_year" => "2010"
      ]
      2 => array:11 [
        "course_id" => "5722343234"
        "subject_number" => "2018"
        "subject_name" => "Season 2018"
        "start_year" => "2018"
        "end_year" => "2018"
      ]
  ]
]```

Please sign in or create an account to participate in this conversation.