- 1262 -

Manipulating arrays with callback functions and Collections

In addition to the previous point, to handle arrays and their elements in PHP (php company), 2 other concepts are interesting. I do not (yet) master them enough to go into too much detail.

The array_map, array_filter or array_reduce functions allow you to process arrays by applying callback functions. We can therefore do without for or foreach while processing all the elements of the array

Collections are third-party libraries, for example very popular in Laravel, which will allow you to manipulate arrays in object logic to have something more readable and pleasant than the functions above:

2 examples in English (the other good practices in this article are also very interesting)
A tutorial in French
The "collect" bookstore on Github
Similar things can be found in other PHP frameworks as well.

Personally, I am always attracted by these programming challenges, it is a good opportunity to rub shoulders with algorithmic complexities, and therefore to dig into the language + in depth, to discuss with other developers on the solutions found, to discover practices, tips, etc. It really allows you to progress as a developer. 2021 is just beginning, I wish you all a very happy new year, rich in code, and good programming practices!


  1. 30 Oct. 2021What is the Enigma of Cladx?1710
  2. 2 Sept. 2021Help Wanted: PHP Development Company is Looking for Skilled Workers1092
  3. 5 Août 2021A Programmer's Guide to PHP478
  4. 14 Mai 2021So what is web development in 2021 ?2125
  5. 14 Avril 2021A perfect means of goal management3178
  6. 21 Fév. 2021The intersection of several arrays6121
  7. 9 Janv. 2021Keep up to date with the latest Php releases1251