-1

我在 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" 的数组的一部分?

4

1 回答 1

1
$array; // Your array.

foreach($array as $subarray) {
    if($subarray['game'] != "Counter-Strike: Global Offensive") {
        unset($subarray);
    }
}
于 2015-01-16T18:09:25.057 回答