Skip to main content
added 4 characters in body
Source Link
scrowler
  • 286
  • 4
  • 9

I always believe that you should use built in functions wherever possible, as opposed to recreating PHP functionality with loops etc. The main reasons for saying this are that (A) we should trust that PHP functions achieve their desired result in an efficient manner, and (B) if they are improved in future versions your code doesn't need to change, but just gets better.:

  1. We should trust that PHP functions achieve their desired result in an efficient manner, and:
  2. If they are improved in future versions your code doesn't need to change, but just gets better.

That being said, why not something like this:

$matches = array_intersect_key($langs, array_flip($allowed_langs));
var_export($matches);

I always believe that you should use built in functions wherever possible, as opposed to recreating PHP functionality with loops etc. The main reasons for saying this are that (A) we should trust that PHP functions achieve their desired result in an efficient manner, and (B) if they are improved in future versions your code doesn't need to change, but just gets better.

That being said, why not something like this:

$matches = array_intersect_key($langs, array_flip($allowed_langs));
var_export($matches);

I always believe that you should use built in functions wherever possible, as opposed to recreating PHP functionality with loops etc. The main reasons for saying this are that:

  1. We should trust that PHP functions achieve their desired result in an efficient manner, and:
  2. If they are improved in future versions your code doesn't need to change, but just gets better.

That being said, why not something like this:

$matches = array_intersect_key($langs, array_flip($allowed_langs));
var_export($matches);
Source Link
scrowler
  • 286
  • 4
  • 9

I always believe that you should use built in functions wherever possible, as opposed to recreating PHP functionality with loops etc. The main reasons for saying this are that (A) we should trust that PHP functions achieve their desired result in an efficient manner, and (B) if they are improved in future versions your code doesn't need to change, but just gets better.

That being said, why not something like this:

$matches = array_intersect_key($langs, array_flip($allowed_langs));
var_export($matches);