$d[]=array("淘宝","930852","http://","0");
$d[]=array("4399小游戏","698523","http://","0");
$d[]=array("天天有喜","689360","http://","0");
$d[]=array("火影忍者","462775","http://","0");
$d[]=array("中国好声音第二季","423689","http://","1");
如何去除二维数组 里$d[4][3] 为 0 的
$d[4][3]="";
楼主想问的到底是什么?是想去除$d[*][3] = "0"的还是想将$d[4][3] 置为"0"?
楼主想问的到底是什么?是想去除$d[*][3] = "0"的还是想将$d[4][3] 置为"0"?
我表达不够准确。
是去除$d[*][3] = "0"的
var_dump(array_filter($d, "foo"));function foo($v){ return $v[3]!=='0';}
你的 $d[0][3]、$d[1][3]、$d[2][3]、$d[3][3] 都为 0,而 $d[4][3] 为 1
你是要删除哪些为 0 的元素吗?
但这不合规则,当用 $d[0][3] 访问时就要八错的 Notice: Undefined offset: 3
考虑清楚再提问
var_dump(array_filter($d, "foo"));function foo($v){ return $v[3]!=='0';}
$ar=array_filter($d, "foo");
print_r(array_values($ar));
function foo($v){
return $v[3]!=='0';
}