hunterstudio.biz
- 1148 -

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!

Web

  1. 2 Sept. 2021Help Wanted: PHP Development Company is Looking for Skilled Workers368
  2. 5 Août 2021A Programmer's Guide to PHP354
  3. 14 Mai 2021So what is web development in 2021 ?2000
  4. 14 Avril 2021A perfect means of goal management3059
  5. 21 Fév. 2021The intersection of several arrays5980
  6. 9 Janv. 2021Keep up to date with the latest Php releases1126