0

I have array which is presenting like this:

        $array = array (
        "list" => array(
            "serwer-1" => 3
        ),
        "servers" => array(
            3 => array(
                "msg" => "{'some data': 123123121313}",
                "status" => 200
            ),
        ),
    );

I want add new items to $array['list'] for example:

        array (
        "list" => array(
            "serwer-1" => 3
            //NEW DATA HERE
            "serwer-2" => 7,
        ),
        "servers" => array(
            3 => array(
                "msg" => "{'some data': 123123121313}",
                "status" => 200
            ),
        ),
    );

Maybe it's trivial, but I haven't any idea how to do this - I have bad day today :(

1
  • 1
    $array['list']['serwer-2'] = 7; Commented Aug 23, 2014 at 19:22

1 Answer 1

1

In order to add a key-value pair to an existing array just do it like the key exists there.

$array["list"]["serwer-2"] = 7;

Then you will get desired result.

Sign up to request clarification or add additional context in comments.

Comments

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.