-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] までの多くの「サブ配列」が含まれる場合があります。必要なもの: 「サブアレイ」を削除する必要がある witch have [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 に答える