Good Day everyone

im having trouble in script right now basically im trying to make an if statement that will assign rate base on the destination, branch ,service and vehicle. which is working fine just a moment ago but when i add another array for another destination it seems that its not using the assigned array but keeps on using the first assigned array

heres the script

`

    $destination ="SM";
    $branch = "Davao International Airport";
    $service = "Transfer In";
    $vehicle = "Vios";
    $destination_10_to_12km_away = array( "WATERFRONT HOTEL" => "WATERFRONT HOTEL",
     "HOTEL ELENA" => "HOTEL ELENA",
      "GRAND REGAL HOTEL" => "GRAND REGAL HOTEL", );

     $destination_13_to_15km_away = array( "MATINA CROSSING" == "MATINA CROSSING",
     "GSIS SUBDIVISION" => "GSIS SUBDIVISION",
      "TIBUNGCO" => "TIBUNGCO",
       "COCA-COLA PLANT" => "COCA-COLA PLANT",
        "ROYAL VALLEY" => "ROYAL VALLEY",
         "SM" => "SM", );


if ((in_array($destination, $destination_10_to_12km_away) && ($branch=="Davao International Airport") && ($service=="Transfer In") || ($service=="Drop Off") && ($vehicle=="Vios"))){
    $rate="350";
    }
   else if ((in_array($destination, $destination_10_to_12km_away) && ($branch=="Davao International Airport") && ($service=="Transfer In") || ($service=="Drop Off") && ($vehicle=="Innova"))){
    $rate="450";
   }
   else if ((in_array($destination, $destination_10_to_12km_away) && ($branch=="Davao International Airport") && ($service=="Transfer In") || ($service=="Drop Off") && ($vehicle=="Van"))){
    $rate="600";
   }
   else{
   $rate="00";
   }

 if ((in_array($destination, $destination_13_to_15km_away) && ($branch=="Davao International Airport") && ($service=="Transfer In") || ($service=="Drop Off") && ($vehicle=="Vios"))){
    $rate="450";
    }
   else if ((in_array($destination, $destination_13_to_15km_away) && ($branch=="Davao International Airport") && ($service=="Transfer In") || ($service=="Drop Off") && ($vehicle=="Innova"))){
    $rate="550";
   }
   else if ((in_array($destination, $destination_13_to_15km_away) && ($branch=="Davao International Airport") && ($service=="Transfer In") || ($service=="Drop Off") && ($vehicle=="Van"))){
    $rate="650";
   }
   else{
   $rate="00";
   }


   echo $rate;

`
which part did i make any mistake?

He guys nevermind figured out already the problem...

thanks anyway

ok no prob..the array is not really the issue but my IF and OR statement

this part or specifically the $service

if ((in_array($destination, $destination_10_to_12km_away) && ($branch=="Davao International Airport") && ($service=="Transfer In") || ($service=="Drop Off") && ($vehicle=="Vios")))

the correct statement is this one

if(in_array($destination, $destination_10_to_12km_away) && ($branch=="Davao International Airport") && ($service=="Transfer In" || $service=="Drop Off") && ($vehicle=="Vios"))

notice the $service it is included in just one ( )

and also i just combine the two if statement in one

commented: Thanks for sharing. +14
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.