Удалить часть массива, если он не содержит

У меня есть массив в php под названием $ json. Это выглядит так

Array (
[0] => Array (
[name] => Knife
[url] => http://steamcommunity.com/market/listings/753/297120...
[price] => 0.16 USD
[image] => http://steamcommunity-a.akamaihd.net/economy/imag...
[quantity] => 30
[game] => Counter-Strike: Global Offensive )

[1] => Array (
[name] => Strange Knife
[url] => http://steamcommunity.com/market/listings/440/Strange%2...
[price] => 0.55 USD
[image] => http://steamcommunity-a.akamaihd.net/economy/imag...
[quantity] => 177
[game] => Team Fortress 2 )

[2] => Array (
[name] => Festive Knife
[url] => http://steamcommunity.com/market/listings/440/Festive%20Knife" id="resultlink_2
[price] => 3.72 USD
[image] => http://steamcommunity-a.akamaihd.net/economy/image/fWFc82js0fmoRAP-qOIPu5THSWqffx
[quantity] => 66
[game] => Team Fortress 2 )

[3] => Array (
[name] => â… Flip Knife
[url] => http://steamcommunity.com/market/listings/7
[price] => 3.72 USD
[image] => http://steamcommunity-a.akamaihd.net/economy/image/fWFc82js0fmoRAP-qOIPu5THSWqffx
[quantity] => 24
[game] => Counter-Strike: Global Offensive )

...

Как я могу удалить часть массива, где GAME! = «Counter-Strike: Global Offensive»?

-1

Решение

$array; // Your array.

foreach($array as $subarray) {
if($subarray['game'] != "Counter-Strike: Global Offensive") {
unset($subarray);
}
}
1

Другие решения

Других решений пока нет …

По вопросам рекламы [email protected]