Xdebug is key when it comes to optimizing PHP code. Today, I heard my colleague boot up a Windows machine just to run an application that could interpret a cachegrind file generated by our development server… surely there must be a Mac equivalent! The following instructions will let you interpret cachegrind files locally on your Mac. Continue reading View xdebug cachegrind files on Mac OS
If you use arrays in PHP, one of the most common tasks you’ll find yourself doing is determining if Item A is in Array X. The function you would probably use in this case is PHP’s in_array.
bool in_array ( mixed $needle , array $haystack [, bool $strict = FALSE ] )
This function works great and I recommend sticking to it when it makes sense. However, when you’re dealing with a very large haystack and need to run in_array() on thousands of values, you’ll discover that in_array isn’t particularly fast when cumulated over thousands of calls. Having recently run into this situation, I set up a little experiment to try two different approaches to in_array().