-1

我有一个数组:

Array




( 
    [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] => 
) 
[3] => Array 
( 
[auth_type] => ani 
[name] => 472367427 
[ani] => 472367427 
[orig_enabled] => Array 
( 
[0] => on 
) 
) 
)`

例如,主数组可能包含从 [1] 到 [10] 的许多“子数组”。我需要什么:我需要删除具有[any] => $todel的“子数组” 例如,$todel = 472367427,这意味着数组必须包含子数组[1]和[3]等等。

4

1 回答 1

0

这很容易unset

$yourIndex = 2;
unset( $yourArray[$yourIndex] ); // this will remove the third element, index: 2

数组索引将unset保持不变,因此如果要重新移动索引,请使用array_splice如下函数:

$yourIndex = 2;
array_splice($yourArray, $yourIndex, 1); // "1" in the last argument indicates how many elements will be removed starting from the $yourIndex value

更多关于:

于 2013-07-09T09:40:56.543 回答