Convert to for loop

Posted on 2014-08-12
Last Modified: 2014-08-12

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.


Question by:mikeysmailbox1
    LVL 84

    Accepted Solution

    $days *= 24;

    Author Closing Comment

    That worked perfectly.


    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    Join & Write a Comment

    Suggested Solutions

    On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
    I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
    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…
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    754 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

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now