Rewrite conditional statement I have this if else block code

 if($_POST["item"]=="All"){
        $notificatioSetting-&gt;AllNotification=$_POST["status"];
    }
    else if($_POST["item"]=="Accept"){
        $notificatioSetting-&gt;AcceptTrackRequest=$_POST["status"];
    }
    else if($_POST["item"]=="Deny"){
        $notificatioSetting-&gt;DenyTrackRequest=$_POST["status"];
    }


this condition continues for almost 12 another else if condition. Beside this and switch, is there a better way?
If you have a lot of conditions I recommend you to use an HashMap (associative array in php) to store the conditions, like this : 

$notificationsItems = [
    "All" =&gt; "AllNotification",
    "Accept" =&gt; "AcceptTrackRequest",
    "Deny" =&gt; "DenyTrackRequest"
];


When you have your pair, you can test all the conditions through a simple foreach: 

foreach ($notificationsItems as $postValue =&gt; $objectAttr) {
    if ($_POST["item"] == $postValue) {
        $notificatioSetting-&gt;{$objectAttr} = $_POST["status"];
        break; //we make an early termination
    }
}


This version mimic exactly the elseifcode. As itzmukeshy7 put in his response, there is a solution with fewer lines of code :

if(in_array($_POST["item"], $notificationsItems)) {
    $notificationSetting-&gt;{$notificationsItems[$_POST["item"]]} = $_POST["status"];
}


In this way adding more conditions will be really easy while making the code more extensible and more decoupled. In addition you'll make explicit the association between a post value and the corresponding attribute in the object, which is good for your futur self or colleague(s).