mercredi 28 juin 2017

I can't use If Statement inside Foreach Statement

Why the if statement inside foreach statement is not working? and my array_search function is also not working, im using yii framework

the if statement should print the brand Name but it prints false, may i know the scenario why the if statement returns me a null value or empty, thank you in advance

function getColumnKey($brand_name){
    $columnKey = '';

        $five_up_brands = array('K'=>"Coke",'L'=>"Sprite",'M'=>"Royal");
       array_search($brand_name, $five_up_brands);

       foreach ($five_up_brands as $k => $v) {

            if($v == $brand_name){

                $columnKey = $k;
            }
       }

    return $columnKey;
}

Aucun commentaire:

Enregistrer un commentaire