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 […]
Late, later and latest PHP checks PHP applies various checks when processing source code. When those checks fail, they might generate a Fatal errorand stop execution. They are the bane of production servers, and every PHP developper tries to avoid them as much as possible (unlike static code analyser authors which try to generate them). […]
Move that foreach() inside the method Several PHP functions work with single or multiple values. For example, array_merge(), which merges several arrays into one. Or, isset(), which checks simultaneously the existence of several variables. str_replace() and preg_replace_callback() also come to mind. This is a good place to move that foreach() inside the method. This approach […]