[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Convert to for loop

Posted on 2014-08-12
2
Medium Priority
?
174 Views
Last Modified: 2014-08-12
Hi

I have a set of if statements and wondered if it could be converted to a shorter format.

  if($days eq 0) { $days = 0; }  
  if($days eq 1) { $days = 24; }  
  if($days eq 2) { $days = 48; }  
  if($days eq 3) { $days = 72; }  
  if($days eq 4) { $days = 96; }  
  if($days eq 5) { $days = 120; }
  if($days eq 6) { $days = 144; }
  if($days eq 7) { $days = 168; }
  if($days eq 8) { $days = 192; }
  if($days eq 9) { $days = 216; }
  if($days eq 10) { $days = 240; }


Not sure what the format would end up being.

Thanks,

Mike
0
Comment
Question by:mikeysmailbox1
2 Comments
 
LVL 85

Accepted Solution

by:
ozo earned 1000 total points
ID: 40257252
$days *= 24;
0
 
LVL 1

Author Closing Comment

by:mikeysmailbox1
ID: 40257262
That worked perfectly.

Thanks
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans
Suggested Courses

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question