Jump to content

.josh

Staff Alumni
  • Posts

    14,780
  • Joined

  • Last visited

  • Days Won

    43

Everything posted by .josh

  1. I just quoted you. Now you have an E.S.T.D. That's what you get for not wearing eCondom.
  2. function getDates($days,$sDate,$eDate,$format = "") { $days = (is_array($days))? $days : array($days); $sDate = strtotime($sDate); $eDate = strtotime($eDate); $dayRange = range($sDate,$eDate,60*60*24); foreach ($dayRange as $d) { if (in_array(date("j",$d),$days)) $daysFound[] = ($format != "")? date($format,$d) : $d; } // end foreach return $daysFound; } // end function getDates $days : Day(s) you want to search for within range. Accepts a single (int) or array of (int). $sDate : Start of date range. Accepts any day/month/year format recognized by strtotime $eDate : End of date range. Accepts any day/month/year format recognized by strtotime $format : (optional) Format of returned dates. See date for how to format. If no format is passed, the unix timestamps are returned. Example use: $days = array(1,8,15,22); $startDate = '2009-06-22'; $endDate = '2009-07-15'; $format = 'Y-m-d'; // passing format $daysFound = getDates($days,$startDate,$endDate,$format); echo "<pre>"; print_r($daysFound); // not passing format $daysFound = getDates($days,$startDate,$endDate); print_r($daysFound); echo "</pre>"; output: Array ( [0] => 2009-06-22 [1] => 2009-07-01 [2] => 2009-07-08 [3] => 2009-07-15 ) Array ( [0] => 1245646800 [1] => 1246424400 [2] => 1247029200 [3] => 1247634000 )
  3. I agree. Sexually Transmitted Diseases are Evil.
  4. weird...that's never happened to me before, and I post regex patterns fairly often, same as you, nrg. What IDE do you use? I'm on vista using html-kit.
  5. lol uh...hmm that is kinda weird. I've never heard of that happening before.
  6. Did you actually read the tutorial? I already gave you brilliant code. Read the tutorial. The tutorial is about swapping numbers, yes. But how it does it, the db query, is what you are looking for.
  7. What's wrong with what I gave you is that I did not escape the brackets because you did not escape them in your OP. That's why I asked about the preg_quote and mentioned what it should be doing, since they weren't escaped. That's why what you have works: you have the brackets escaped in the code you just now posted. Kind of scratching my head about why you would post what you currently have, but remove the escapes? (\[sp(?:oiler)?\](.+?)\[\/sp(?:oiler)?\])
  8. http://www.phpfreaks.com/tutorial/php-custom-list-order
  9. I'm kind of interested in how that really works for you when [...] signifies a character class, and
  10. I understand that they are not the same thing and in a broader scope they will not yield the same results, but I said they effectively do the same thing, and that's because in this context (for the OP's needs) they will give him what he needs all the same.
  11. For one thing, Fibonacci sounds dirty.
  12. Nope... truncation rounds towards 0 where as flooring rounds towards -∞. Further explain? If I have for example 5.5 if I were to cast it as an int it would chop off the .5 and make it 5. If I have 5.5 and do floor(5.5) it rounds down to nearest integer, making it 5 just the same. So if I have for ($x = 0; $x < 5; $x += .1) { $a = (int) $x; $b = floor($x); echo "$a $b <br/>"; } All the numbers would match up: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 That makes them effectively the same thing. I mean, I get what you're saying; if you do for instance floor(-5.5) you will get -6, whereas (int) -5.5 would yield -5. But that's not applicable in this situation.
  13. here's a tip: typing http://www.php.net/functionhere will take you to the manual entry of the function (or a list of suggestions if you misspelled it or suggestions of something that might be useful) Also I don't think a whole lot of people here know that you can do [m]function[/m] on these boards and it will auto-link to the manual.
  14. That's because you didn't assign it to anything. $resultp = floor($percent/9 * 100);
  15. If you just want the first img src: preg_match('~<img[^>]*src\s?=\s?[\'"]([^\'"]*)~i',$string,$imgsrc); echo $imgsrc[1]; If you want the whole tag: preg_match('~<img[^>]*>~i',$string,$imgsrc); echo $imgsrc[0];
  16. probably the same person who added the other word filters. IMO they should be nixed altogether.
  17. er...I don't get it. round() is a pre-made function, too.... And casting as an int effectively does the same thing as floor(). The line of code I posted was his code that he's already using. I just inserted a cast type into it.
  18. Ah damn. How did I miss that? Probably because I am
  19. Oh hey I just noticed there's a booze smiley, but not a cigarette smiley?
  20. $resultp = (int) $percent/9 * 100; edit: well that will simply chop it off. If you want to round to nearest whole number, use round
  21. $colors = array('ce bc1','ce'); $colors[$i++ % 2]; example: $colors = array('ce bc1','ce'); while ($list = mysql_fetch_array($result)) { echo $colors[$i++ % 2]; }
  22. yeah unfortunately, it will still be quite a while before I can tell my boss to tell the client they are being unreasonable for expecting me to cater to IE6 users. Can you believe I just barely get away with saying "no" to IE5? Too many people out there either need to get with the program or at least trust the people who do.
  23. OR die(mysql_error()); will spit out the error mysql generates if there is a problem with executing the query. Use it for debugging. Remove it when done. Although this sounds like a one-time-use script anyways, so whatever.
  24. Right. But when you explode at the "at" you are left with a 2 element array. One with '24th Dec 2009' and one with '13.19' well you turn around and use mktime with those individual number separated (and even converted, like Dec->12) well you sort of skipped the steps involved in having to go from your explode to your mktime... with what I posted, I start out with the string from the old table just the same. I then remove the 'at' and strtotime it, which does all that stuff you skipped in your code, plus what mktime does.
×
×
  • 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.