0

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?

2
Contributors
3
Replies
21
Views
4 Years
Discussion Span
Last Post by ehpratah
1

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

Edited by ehpratah: correction

Votes + Comments
Thanks for sharing.
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.