php去掉二维数组中某key的值
eg:二维数据
$arr = array( array('game_id'=> 111, 'login_type' => 3, 'num' => 339), array('game_id'=> 111, 'login_type' => 3, 'num' => 339), array('game_id'=> 111, 'login_type' => 3, 'num' => 339) );
方法1:
$string = preg_replace('/"game_id":\d+\w+,/', '', json_encode($arr)); print_r($string);
方法2:
foreach($arr as &$v) unset($v['game_id']); print_r($arr);
result:
Array ( [0] => Array ( [login_type] => 3 [num] => 339 ) [1] => Array ( [login_type] => 3 [num] => 339 ) [2] => Array ( [login_type] => 3 [num] => 339 ) )