Bir foreach yerine numaraları harfleri atama

0 Cevap php

Ben şöyle bir dizi var.

$ARR_MSDS=array(
'K' => "Latex Warning: Caution this product contains natural rubber latex, which may cause allergic reactions!",
'L' => "Additional Shipping Charges: Please note that standard shipping costs do not apply.  This item requires an oversized and/or overweight shipping surcharge. Total shipping charges will be calculated upon receipt of order and you will be called with exact total.",
'M' => "Bariatric Rated: Please note that this product has a Bariatric rating." ,
'B' => "HazMat: Non-returnable.  This item is classified as a hazardous material by DOT and has the following shipping restrictions: ground shipping only (no air shipments) and only ship to the 48 continuous states.  Additional shipping charges may apply.",
'P' => "Refrigerated Item: Shipped on ice only Monday - Wednesday.",
'E' => "Prescription Drug or Device: This item may only be sold to a licensed healthcare facility.",
'A' => "Special Order: This item is a special order and is non-returnable.  Please ensure this is the item you want.  If you have any questions, please contact us.  It may be drop shipped from the manufacturer.",
'X' => "Earth-Friendly: This item is certified Earth-Friendly.",
'V' => "Controlled Drug: Requires a DEA license and may only be shipped to the address on the license.",
10  => "Class II Drug:  Non-refundable.  This drug requires an original DEA Form 222 to be in our hands prior to shipping your order.  Please contact us if you require assistance.",
'T' => "No Return: Cannot be sent back.",
'C' => "Short-Dated Item: This item has a shorter shelf life, usually less than 6 months, and is priced accordingly.  This item is non-returnable."

);

Benim müşteri veritabanında harfleri yerine numaralarını kullanmaya karar verdi. Ben onlar karşılık gelen harfler numaralarını kullanarak değildir ve gerçekleşmesi gereken ne yürütmek için bir foreach kullanın.

İşte benim foreach.

foreach($ARR_MSDS as $k=>$v){
    $imgPArry  = explode(":",$v);
    $imgPath   = $imgPArry[0];
    $imgTile =  "<span ><strong>".$imgPArry[0]."</strong>";
    $imgTile1 = $imgPArry[1];
    if($imgPArry[2]!='')
    {
        $tileMain = $imgTile ." :".$imgTile1." ".$imgPArry[2]."</span>";
    }else{
        $tileMain = $imgTile ." :".$imgTile1."</span>";
    }
    if(is_array($MSDS_LIST)){
        //onmouseover=\"Tip('<strong>Please call customer service at 1(800) 748-5665 to order item</strong>', BALLOON, true, ABOVE, true, OFFSETX, -17)\"
        $MSDS_LIST_RESULT.=(in_array($k,$MSDS_LIST))?"<img src='/images/msdx/$imgPath.gif' onmouseout=\"hideDiv()\" onmouseover=\"showDiv('$tileMain')\"   style='padding:2px;margin:0px;'>":"";
    }
    else{
        $MSDS_LIST_RESULT=($k==$MSDS_LIST)?"<img src='/images/msdx/$imgPath.gif'   title='$v' style='padding:2px;'>":"";
    }
    }

$ MSDS_LIST bu gibi görünen bir dizidir.

Array ([0] => R)

0 Cevap