array_filter() versus Loop Condition Checks

https://www.php.net/array_filter

array_filter() versus Loop Condition Checks Optimizing your code for performance is important, especially when dealing with large arrays or complex data structures. One common dilemma developers face is whether to use array_filter() to preprocess an array before a loop or to check a condition inside the loop and skipping the unwanted values. In this blog […]

Array, classes and anonymous classes memory usage

Printing press characters in their boxes

I have been working with a code base that uses a lot of arrays as hashes recently. This is a style that I am confortable with, as I do enjoy PHP arrays : flexible, powerful, versatile. Who don’t like them? Yet, I keep hearing that classes are more memory efficient than arrays. Yet, I still […]

Unraveling the Quest for the Fastest Case Insensitive Char Comparison in PHP

Recently, I delved into a piece of code that involved a case-insensitive comparison of a character to a specific letter. The code, though straightforward, had room for optimization. Not being a fan of lengthy logical expressions, my curiosity led me to explore ways to make it more concise and potentially faster. What is the fastest […]

array_filter() versus Loop Condition Checks

array_filter() versus Loop Condition Checks Optimizing your code for performance is important, especially when dealing with large arrays or complex data structures. One common dilemma developers face is whether to use array_filter() to preprocess an array before a loop or to check a condition inside the loop and skipping the unwanted values. In this blog […]