0

I have one array as follows :

    Array
    (
        [154541] => Array
            (
                **[3831211] => Array
                    (
                        [34443] => 34443
                        [34444] => 34444
                        [34438] => 34438
                        [34442] => 34442
                        [34450] => 34450
                    )**

            )

        [154514] => Array
            (
                **[3830597] => Array
                    (
                        [34442] => 34442
                        [34450] => 34450
                        [34443] => 34443
                        [34444] => 34444
                        [34438] => 34438
                    )**

            )

        [154477] => Array
            (
                **[3829564] => Array
                    (
                        [34442] => 34442
                        [34444] => 34444
                        [34438] => 34438
                        [34450] => 34450
                        [34443] => 34443
                    )**

                [3830046] => Array
                    (
                        [34442] => 34442
                        [34444] => 34444
                        [34443] => 34443
                        [34438] => 34438
                        [34450] => 34450
                    )

            )

        [154474] => Array
            (
                [3829402] => Array
                    (
                        [34442] => 34442
                        [34450] => 34450
                        [34443] => 34443
                        [34438] => 34438
                        [34444] => 34444
                    )

            )

        [154472] => Array
            (
                [3831553] => Array
                    (
                        [34443] => 34443
                        [34450] => 34450
                        [34438] => 34438
                        [34444] => 34444
                        [34442] => 34442
                    )

                [3829803] => Array
                    (
                        [34443] => 34443
                        [34444] => 34444
                        [34450] => 34450
                        [34442] => 34442
                        [34438] => 34438
                    )

                [3829802] => Array
                    (
                        [34443] => 34443
                        [34444] => 34444
                        [34438] => 34438
                        [34450] => 34450
                        [34442] => 34442
                    )

                [3831552] => Array
                    (
                        [34444] => 34444
                        [34450] => 34450
                        [34443] => 34443
                        [34442] => 34442
                        [34438] => 34438
                    )

                [3830078] => Array
                    (
                        [34444] => 34444
                        [34442] => 34442
                        [34443] => 34443
                        [34438] => 34438
                        [34450] => 34450
                    )

            )
)

Now I want to replace the inner array(I have made that inner array as ** in above array) with my new generated array called $alerts.

I am not getting how to replace that inner-array with $alerts array.

1 Answer 1

1

This should do the trick.

$array[154541] = array("3831211" => $alerts);

or if the inner array has more elements:

$array[154541][3831211] = $newData;
Sign up to request clarification or add additional context in comments.

2 Comments

I want to replace whole 3rd inner array.Not any single element.
Yes so what is the problem with that?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.