I have this issue with multidimensional arrays. I have an array having user login . Given the following multidimensional array:
                    $data = [
                    [
                        "_id" => "6318956768e7df9342bc8349",          
                        "userid" => "test1234AB", 
                        "lastlogindate" => "2022-10-31T12:21:23.000000Z",  
                    ], 
                    [
                        "_id" => "6318956768e7df9342bc8350",
                        "userid" => "test123456",
                        "lastlogindate" => "2022-08-31T12:21:23.000000Z",
                    ],
                    [
                        "_id" => "63357dfd5435bcdfae485685",
                        "userid" => "test1234AB",
                        "lastlogindate" => "2022-12-31T12:21:23.000000Z",
                    ] ,
                             
                    [
                      "_id" => "63357dfd5435bcdfae98316",  
                        "userid" => "xyz123", 
                        "lastlogindate" => "2022-12-31T12:21:23.000000Z",
                    
                    ] 
                ]; 
if having the same userid having multiple login so the lastlogindate will in same array(if userid) . I need output like
                Array
                (
                    [0] => Array
                        (
                            [_id] => 6318956768e7df9342bc8349
                            [userid] => test1234AB
                            [lastlogindate] => Array
                                (
                                    [0] => 2022-10-31T12:21:23.000000Z
                                    [1] => 2022-12-31T12:21:23.000000Z
                                )
                        )
                    [1] => Array
                        (
                            [_id] => 6318956768e7df9342bc8350
                            [userid] => test123456
                            [lastlogindate] => Array
                                (
                                    [0] => 2022-08-31T12:21:23.000000Z
                                )
                        )
                    [3] => Array
                        (
                            [_id] => 63357dfd5435bcdfae98316
                            [userid] => xyz123
                            [lastlogindate] => Array
                                (
                                    [0] => 2022-12-31T12:21:23.000000Z
                                )
                        )
                )
How can I do that??
 
    