Question: I have an array:

```
    $data = array(
        'loggedin' => false
    );

```

i want to add other keys as well their values if the user is logged in so i use:

```
    if ( $this->auth_model->loggedin()){//user is logged in
        $data["loggedin"] = true;//set to true
        $data["user_id"] = $this->session->userdata["uid"];//add new key with its value on $data array
    }

```

is this the best way to do it or should i use `array_push` and such?

Answer: 
No need to add overhead by calling a function (like array\_push).

Yes. That's the way to do it.
i don't think you can use [array\_push](http://php.net/manual/en/function.array-push.php) to add values to an associative array, so it's ok to do as you are doing