Jump to content

count the number of variables that qualify for if statement?


a2bardeals

Recommended Posts

so i have a foreach statement that includes an if statement. There are say, 5 camcorder tapes with the corresponding variables representing the length of each tape.

$tape1 = 30
$tape2 = 60
$tape3 = 30
$tape4 = 90
$tape5 = 30

from get action of a form i have these variables carry over to the next page where i will try to decide which/how many tapes can fit on a 2 hour dvd or which ones need multiple dvds. eg. if 3 tapes are 30 min and 1 tape is 180 min i can fit the 30 min 3 tapes on one 2 hour dvd but the 180 min will require 2 dvds. (this will eventually genereate a price quote for how many master dvds company_x has to make)

ok, so i have the following code:
[code]
foreach ( range(1, $no_of_tapes) as $number){
$name = 'tape'.$number;
  if ($_GET[$name] == 30){

// **HERE IS WHERE I NEED TO COUNT THE NUMBER OF TAPES THAT ARE 30 MIN AND DIVIDE THAT NUMBER BY 4 WHICH WILL GIVE ME THE NUMBER OF DVDS NEEDED.

  }elseif ($_GET[$name] == 60{

// **AGAIN I NEED TO COUNT THE NUMBER OF TAPES THAT ARE 60 MIN AND DIVIDE THAT NUMBER BY 2 WHICH WILL GIVE ME THE NUMBER OF DVDS NEEDED.

  }

}

is this easy to do or even possible?[/code]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.