[PHP] Re: slicing and dicing strings
On 6/27/2012 6:15 PM, Kirk Bailey wrote: ok, it slices and dices, but how? in python, to print all but the last char in string FOO, we say print FOO[:-1] But this seems to bark like a basset hound in php. Whyfore? Now tihs tyro is seeking sage words to help me understand this. RTFM is not sage words; if you don't want to help me please don't waste the bandwidth. Would anyone care to help me understand this without dedicating 4 precious and in over demand/under supply hours to RTFM? print substr($foo, 0, -1); You could also do this, but it takes more code: print substr($foo, 0, strlen($foo) - 1); You could wrap it as a function like so: function strchop($string, $num_chars_to_chop_off_end) { return substr($string, 0, -$num_chars_to_chop_off_end); } If you have time, the relevant manual page is: http://www.php.net/manual/en/function.substr.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: php batch/queue framwork
On 6/28/2012 11:58 AM, Tom Sparks wrote: I am looking for a batch/queue framework that is database-centric? I could write my own, but I want one that is mature tom_a_sparks It's a nerdy thing I like to do You could try Amazon Simple Queue Service: http://aws.amazon.com/sqs/ Use the PHP SDK: http://aws.amazon.com/sdkforphp/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] add one day to DateTime based on timestamp
Hello, When I create a DateTime object from a UNIX timestamp, and then add a one day interval, PHP adds 25 hours instead of 24. Is this a bug, or something to do with the time zones? Here are the commands I'm running from my shell: -- $ date Wed Jun 13 06:08:24 PDT 2012 $ php -r '$d=new DateTime(@108200); print $d-format(r).\n; $d-add(new DateInterval(P1D)); print $d-format(r).\n;' Tue, 20 Apr 2004 07:00:00 + Wed, 21 Apr 2004 08:00:00 + -- If I set the time zone on the new DataTime object to America/Los_Angeles before adding the 1 day period, then it works as expected. -- $ php -r '$d=new DateTime(@108200); $d-setTimeZone(new DateTimeZone(America/Los_Angeles)); print $d-format(r).\n; $d-add(new DateInterval(P1D)); print $d-format(r).\n;' Tue, 20 Apr 2004 00:00:00 -0700 Wed, 21 Apr 2004 00:00:00 -0700 -- Regards, Shailesh -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php