PHP Arrays: Loop trough array with a lot of conditional statements. Help / Best practices
Posted
by Jonathan
on Stack Overflow
See other posts from Stack Overflow
or by Jonathan
Published on 2010-05-18T14:16:32Z
Indexed on
2010/05/18
14:20 UTC
Read the original article
Hit count: 310
Hi, I have a problem I don't know how to get it to work the best way.
I need to loop trough an array like the one below. I need to check if the [country] index is equal to a Spanish speaking country (lot of countries) and then get those [title] indexes of the correspondent country and check for duplicates.
The original array:
Array
(
[0] => Array
(
[title] => Jeux de pouvoir
[country] => France
)
[1] => Array
(
[title] => Los secretos del poder
[country] => Argentina
)
[2] => Array
(
[title] => Los secretos del poder
[country] => Mexico
)
[3] => Array
(
[title] => El poder secreto
[country] => Uruguay
)
)
To help you understand, the final result I need to get looks something like this:
Array (
[0] => Array
(
[title] => Los secretos del poder
[country] => Argetnina, Mexico
)
[1] => Array
(
[title] => El poder secreto
[country] => Uruguay
) )
© Stack Overflow or respective owner