I just sent in my first Xdebug patch. It implements bug/feature request #416 – seems the computerized format for function calls didn’t output the return value.
This is the patch :XDebug bug #416 patch
I just sent in my first Xdebug patch. It implements bug/feature request #416 – seems the computerized format for function calls didn’t output the return value.
This is the patch :XDebug bug #416 patch
Somewhere in december, I promised to publish articles and other interesting things on a regular basis. So far, not much of that has happened.
Not that I was short of ideas, but due to time-contraints, I never got around to doing that.
In the past few weeks, I finally found the time to put some of those ideas into practice. So starting this week, you’ll regularly see some articles and smaller tidbits posted here.
A small preview of what’s the come :
For those of you who want to know when a new article is added, you can subscribe to the feed or follow me on Twitter (@wimgtr)
Important : the following technique doesn’t work for any arrays where the values are :
Suppose you get data from some source (an XML file, a CSV file, …) and you put it into an array. Now suppose this data is full of duplicates. For example, you have :
array(
0 => 'horse',
1 => 'pig',
2 => 'pig',
3 => 'cow',
4 => 'horse',
...
How can you get the unique values from this array ?
The standard way would be to do :
$a = array_uniques($a);
Works fine, except that it’s extremely slow for large arrays.
A better way would be :
$a = array_keys(array_flip($a));
But marginally faster is :
$a = array_flip(array_flip($a));
So how big is the speed difference ? For large arrays, a double array_flip can easily be 20 times faster.
For reference, here’s a small benchmark :
$a = array();
for ($x=0; $x < 1000000; $x++) {
$a[] = rand(0,1000);
}
$starttime = microtime(true);
$b = array_unique($a);
echo (microtime(true) - $starttime) . "\n";
$starttime = microtime(true);
$b = array_keys(array_flip($a));
echo (microtime(true) - $starttime) . "\n";
$starttime = microtime(true);
$b = array_flip(array_flip($a));
echo (microtime(true) - $starttime) . "\n";
The result :
2.06489086151
0.101167201996
0.0999970436096
Over the past 2 years I’ve used Zend Framework for several projects and played with the autoload functionality of Zend_Loader, as well as using standard include statements.
Ever since Zend released its first version of Zend Framework, discussions have been going on about what the best way to autoload files/classes is. Some people even claim autoloading is simply a bad idea and we should use include/include_once/require/require_once (another never ending debate there).
Continue reading Autoloading in Zend Framework – how (not) to do it
So I finally got around to writing a professional blog. I’ve been planning on starting one for a long time, but never got around to actually doing it, mostly due to time constraints.
This blog serves just one purpose : to publish the ideas that sometimes pop into my head, often while working on a technical solution, sometimes while thinking about a business idea or just while browsing the Web.
It will be a collection of long, technical or business oriented articles, often mixed with short and succinct items… mostly thoughts about IT, business or anything else that I may find interesting.
My main goal is for this blog to serve as a historical record for myself… if by any chance someone else enjoys reading it, it’ll have served more than its purpose !
By continuing to use the site, you agree to the use of cookies. more information
The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.