vendredi 18 décembre 2015

How can i improve this if/else condition?

Is there anyway to improve the below lines of code,

$cnt = 0 ;
$search = array();
foreach($v as $type) {
    if (isset($vehicleType[$type]['count'])) {
        $cnt = $cnt + $vehicleType[$type]['count'];
    } elseif (isset($superStructure[$type]['count'])) {
        $cnt = $cnt + $superStructure[$type]['count'];
    } else {
        $cnt = $cnt + 0;
    }
    $search[]  = urlencode($type);
}

Any help would be greatly appreciated.

Aucun commentaire:

Enregistrer un commentaire