Optimise me!

    Date: 12/01/07 (PHP Community)    Keywords: no keywords

    This looks repetitive, anyway to make it better?

    $arr_bits is basically a date (exploded at '/' from YYYY/MM/DD/).

          if (!empty ($arr_bits[2])) {
            $this->minTimeStamp = mktime (0, 0, 0, $arr_bits[1], $arr_bits[2], $arr_bits[0]);
            $this->maxTimeStamp = mktime (23, 59, 59, $arr_bits[1], $arr_bits[2], $arr_bits[0]);
          //  If there's no day but there is a month, get the first and last second of the month
          } elseif (!empty ($arr_bits[1])) {
            $this->minTimeStamp = mktime (0, 0, 0, $arr_bits[1], 1, $arr_bits[0]);
            $this->maxTimeStamp = mktime (23, 59, 59, $arr_bits[1], date ('t', $min_timestamp), $arr_bits[0]);
          } elseif (!empty ($arr_bits[0])) {
            $this->minTimeStamp = mktime (0, 0, 0, 1, 1, $arr_bits[0]);
            $this->maxTimeStamp = mktime (23, 59, 59, 12, 31, $arr_bits[0]);
          }
    


    Thanks ^^;;

    Source: http://community.livejournal.com/php/600874.html

« Variable Functions w/... || Preventing SQL Injection »


antivirus | apache | asp | blogging | browser | bugtracking | cms | crm | css | database | ebay | ecommerce | google | hosting | html | java | jsp | linux | microsoft | mysql | offshore | offshoring | oscommerce | php | postgresql | programming | rss | security | seo | shopping | software | spam | spyware | sql | technology | templates | tracker | virus | web | xml | yahoo | home