假設我有在PHP這樣的陣列:如何從PHP中刪除數組中的索引?
$ray =
Array
(
[0] => Array
(
[id] => 1
[0] => 1
[ip] => 127.0.0.1
[1] => 127.0.0.1
[username] => local_me
[2] => local_me
[last_visit] => 2013-05-17 02:12:07
[3] => 2013-05-17 02:12:07
)
[1] => Array
(
[id] => 2
[0] => 2
[ip] => 127.2.2.3
[1] => 127.2.2.3
[username] => Anonymous42
[2] => Anonymous42
[last_visit] => 2013-05-16 16:07:46
[3] => 2013-05-16 16:07:46
)
)
我想刪除ip
(和「1」也)此數組的所有元素「列」。我怎樣才能做到這一點?
謝謝!
謝謝!我想我懶得寫兩行代碼:) – void
@Mark Parnell,你爲什麼在'&$ item'處使用'&'? – Luis
要傳遞該項[通過引用](http://php.net/manual/en/language.references.php),以便更新原始數組。 –