我有一个包含其他数组(子数组)的数组。我需要获取包含特定键值的子数组的索引。例如。这是我的阵列:Php数组索引
Array
(
[0] => Array
(
[id] => 353
[name] => account_2
[ips] =>
[tech_prefix] =>
[password] =>
[id_voip_hosts] =>
[proxy_mode] =>
[auth_type] => ani
[ani] => 526466
[accname] =>
[protocol] =>
[port] =>
[orig_enabled] => 1
[term_enabled] =>
[orig_capacity] =>
[term_capacity] =>
[orig_rate_table] =>
[term_rate_table] =>
[id_dr_plans] =>
[orig_groups] =>
[term_groups] =>
[notes] =>
)
[1] => Array
(
[id] => 352
[name] => account_3
[ips] =>
[tech_prefix] =>
[password] =>
[id_voip_hosts] =>
[proxy_mode] =>
[auth_type] => ani
[ani] => 1345436
[accname] =>
[protocol] =>
[port] =>
[orig_enabled] => 1
[term_enabled] =>
[orig_capacity] =>
[term_capacity] =>
[orig_rate_table] =>
[term_rate_table] =>
[id_dr_plans] =>
[orig_groups] =>
[term_groups] =>
[notes] =>
)
[2] => Array
(
[id] => 354
[name] => account_4
[ips] =>
[tech_prefix] =>
[password] =>
[id_voip_hosts] =>
[proxy_mode] =>
[auth_type] => ani
[ani] => 472367427
[accname] =>
[protocol] =>
[port] =>
[orig_enabled] => 1
[term_enabled] =>
[orig_capacity] =>
[term_capacity] =>
[orig_rate_table] =>
[term_rate_table] =>
[id_dr_plans] =>
[orig_groups] =>
[term_groups] =>
[notes] =>
)
)
我需要什么。例如,我需要从数组子数组[2]中删除。我知道unset($ myarray [2])的一种方式,但我怎样才能得到这个索引[2]。如果我只知道[ani]键值472367427.如何在var中获取这个“[2]”以将其插入到未设置的命令中。 如果我需要删除有一个密钥[ani] = 1345436的子数组(它在数组[1]中)。有没有办法通过一个键的值来搜索数组的索引。 再次,如何通过[ani]键在多维数组中找到这个索引[2]或[1]? 谢谢!
以何种方式,你导航到每个[ANI]价值指数和
unset
元素?通过循环? –循环和'unset'或'array_filter'。这是非常基本的数组操作的东西,尝试一些东西。 – deceze
有什么我们失踪的?你有什么尝试? – jterry