Filtering with array functions [part 3]

Filtering with array functions [part 3]

Did you know that there are two ways to work with arrays?

In the previous episodes of this series dedicated to array functions in PHP, you saw the basics on how to create arrays and some fundamental functions.


Today you will go all in with filtering elements within arrays.

In fact, there are two distinct methods when working with arrays.

The first is looping through all the elements inside (even if you know you don't need them).

This is not a very fast method, as you have already understood this method is rather confusing and slow.

You'll probably have worked with arrays with tens or hundreds of elements,

not ideal isn't it?

The second method is very fast but it will make your life a lot easier.

This is the power of filtering!


Over the years PHP has grown so much in this respect and, to this day, it provides dozens of functions that filter array elements depending on the features you decide to use.

They range from the most standard using a single parameter, to incredibly customized using callbacks and more.

Unfortunately, not everyone is able to use them effectively.

From today you will become one.

Read the full article here

To view or add a comment, sign in

More articles by Nico Anastasio

  • The Role of a Model in an MVC Framework

    Here is one of the first errors I made at the beginning of my career. After a learned the initial concepts of the MVC…

  • How to use API in PHP (with Example)

    APIs have become an integral part of web development over the past decade, enabling seamless communication between…

  • Builder in PHP [Design pattern with examples]

    Have you ever thought about how movies are made? If you stop for a second and reflect on it for a minute you will soon…

  • Git for PHP developers [branches]

    Parallel universe, We all have grown up watching movies and reading fantasy books about different universes. Some of…

  • Git for PHP developers [the basics]

    Did you ever found yourself in the situation of having to edit some file, realised that you made a mistake or the…

  • Containerize your PHP application (Docker 101)

    It's 2020, things have changed quickly in the last few years, We used to work with local web servers such as MAMP and…

    2 Comments
  • The PHP 7.4 series (Deprecations)

    Tell me if one of these situations has ever happened to you - The head coach of your favourite team substituted a…

  • The PHP 7.4 guide (new features)

    Beginner developers on the facebook group often ask me questions like: What is the next amazing tool they need to…

  • Composition over Inheritance [example in PHP]

    Let me ask you a few direct questions: > Did you ever come back after a year to an old application to add new features?…

  • The one model to truly develop your ideas

    Hi there, Did you know that each of us will have at least 33 successful ideas over our lifetime?. Ideas that can change…

Insights from the community

Others also viewed

Explore topics