 | News Feed |
Sections
|
| feed this: |  |
Brian Moon's Blog: in_array is quite slow
by Chris Cornutt June 06, 2008 @ 09:36:47
Brian Moon had a problem - one of his cron jobs was lasting for much longer (hours!) than it should have been. He tweaked, tested and debugged the script and finally came down to a call to in_array, something he comments on as being "quite slow".
See, this job is importing data from a huge XML file into MySQL. After it is done, we want to compare the data we just added/updated to the data in the table so we can deactivate any data we did not update. [...] We then compared the two arrays by looping one array and using in_array() to check if the value was in the second array. [...] So, that was running for hours with about 400k items. Our data did not contain the value as the key, but it could as the value was unique.
He method, replacing the in_array call that had to do a full array scan for each time through the loop with an isset/unset combo on the unique key, changed the execution time down from about 4 hours to 0.8 seconds.
voice your opinion now!
inarray compare array unset isset unique key execution time
Hasin Hayder's Blog: WorldTimeEngine - How about making your own in PHP?
by Chris Cornutt March 10, 2008 @ 11:17:00
Hasin Hayder has posted an example of a "world time search" he's worked up that uses the geonames.org and Yahoo! developer APIs to pin down the time at any given location.
I recently came by this site WorldTimeEngine where users can search the local time of any place using the name, street address or just latitude and longitude. Since that time I was thinking how easily you can make your own. As long there are some good people over there (For Geocoding API) - its a not a big deal, you know?
His script pulls the location of the place (latitude/longitude) from the Yahoo! geocoding API and passes that back into the geonames web service to get the local time. The result is an array with the lat/long, address you submitted and the time output in a standard string.
voice your opinion now!
world time engine example yahoo api webservice geonames
SitePoint WebTech Blog: Give Your Visitors a Rough Time
by Chris Cornutt March 06, 2008 @ 08:44:00
In a new post to the Web Tech blog over on SitePoint, Toby Somerville has posted something he calls "RoughTime" - his method for displaying a more "human friendly" output of a timestamp.
When asked the time, we generally don't need to be military accurate with our response [...] we generally communicate the approximate time. i.e. 'its nearly ten' or 'its just gone half past three'. Yet on the web, time is generally shown as '12:24:13 AM', or similar â'" not very visitor friendly.
His RoughTime uses two switch statements to map the hour and minute values to different strings. For example, minutes between 15 and 20 become "quarter past" and the hours are changed over from numeric versions to their word counterparts.
voice your opinion now!
roughtime switch approximate time hour minute translate
PHPWomen.org: elePHPants
by Chris Cornutt January 18, 2008 @ 07:56:00
To help "sweeten the deal" a bit and encourage you to give towards the causes that the PHP Women are trying to accomplish, they're offering a special little bonus for those who donate at a certain level:
Cal Evans from the Zend DevZone - being the awesome guy that he is - has graciously offered to mail out to the first 10 people who donate to PHPWomen $50 or more, a PHP elePHPant. Yep - you get one of the hard to find and much sought after plushy PHP elePHPants.
You can find out more about the goals for their fund raising in this other post to the PHPWomen.org blog as well as information on submitting whatever you feel like donating (time or money).
voice your opinion now!
elephpants stuffed toy donate money time phpwomen
Nessa's Blog: Common PHP Errors
by Chris Cornutt December 10, 2007 @ 12:05:00
Nessa has set up a post in an effort to help budding PHP developers out there with some of the most common problems they might come across in their work and how to handle them a bit more gracefully with error handling:
I'm going back to the basics here, you know, when you wrote your first PHP script and saw an ugly-ass error message pop up on your screen? Error messages are the best tool a programmer has.
She talks about how to set up the error reporting first, making sure that you're getting things up and useful. From there she describes some of the common errors that you might see including:
- Parse errors
- MySQL Result source errors
- Stream errors
- Max Execution Time errors
Check out the rest of the post for more types.
voice your opinion now!
error handling parse mysql resource stream execution time error handling parse mysql resource stream execution time
NewsForge.com: A DIY calendar control in PHP
by Chris Cornutt January 26, 2007 @ 15:25:00
As a former ASP.Net coder, I've missed the convenience of Microsoft's built-in Calendar Control since I switched to doing Web site development in PHP. On a recent project I needed the ability to display a calendar with dates serving as hyperlinks to selected database items. I decided to use the opportunity to write some portable PHP code that I could use in other projects.
So started Donald McArthur's work on creating a simple, easy to use calendaring system to be used in a popup inside an application. He provides all the code you'll need - the PHP code and the HTML layout/functionality you'll need to get it working.
He helps you visualize the structure of the end result HTML table with a simpler version (three cells by five cells) and explains the date functions the code uses to figure out the dates and days of the selected month.
voice your opinion now!
diy calendar date time function control table diy calendar date time function control table
|
Community Events
Don't see your event here? Let us know!
|