NOMGUY
7 months ago
112
2
Laravel

Merge same array

Posted 7 months ago by NOMGUY

I have two arrays within an array:

Array
(
    [0] => Array
        (
    [id] => 1
            [advisors] => Array
                (
                    [0] => Array
                        (
                            [first_name] => Johns
                            [last_name] => rep_last0
                        )

                    [1] => Array
                        (
                            [first_name] => Janes
                            [last_name] => rep_last1
                        )
                )
        )
     [0] => Array
        (
        [id] => 2
            [advisors] => Array
                (
                    [0] => Array
                        (
                            [first_name] => test
                            [last_name] => user
                        )
                )
        )
)

What I want it.. it should show something like this.

Array
(
    [0] => Array
        (
            [advisors_name] => Johns rep_last0, Janes rep_last1
        )
     [0] => Array
        (
            [advisors_name] => test user
        )
)

How can I do that?

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