How to conditionally append an associative element to an array
23:36 05 Dec 2013

I have the following code to update my database.

$users = Sdba::table('tabusuarios');
$users->where('User_Id =', $User_Id);
$data = array('User_Name' => $User_Name, 'User_Email' => $User_Email, 'User_Status' => $User_Status, 'User_Perm' => $User_Perm);
$users->update($data);

I want to also update 1 more column if the data is submitted. Something like this

if ($_POST["User_Password"])
    $data = array('User_Password' => saltSenha($_POST["User_Password"]));

How can I conditionally add this element to my $data array?

php arrays conditional-statements