2012-01-27 229 views
0

我有陣列狀的下方,如何在取消設置數組值後設置鍵值?

Array 
(
    [14289] => Array 
     (
      [0] => Karthikeyan 
      [1] => Mathi 
      [2] => RAvi 
     ) 

    [14279] => Array 
     (
      [0] => Karthikeyan 
      [1] => Mathi 
      [2] => RAvi 
     ) 

    [14288] => Array 
     (
      [0] => Karthikeyan 
     ) 

    [14291] => Array 
     (
      [0] => Mathi 
     ) 

    [14284] => Array 
     (
      [0] => RAvi 
     ) 

) 

如果我取消設置索引[1]從[14289]這一個值。之後,該陣列顯示器等下面,

Array 
(
    [14289] => Array 
     (
      [0] => Karthikeyan 
      [2] => RAvi 
     ) 

    [14279] => Array 
     (
      [0] => Karthikeyan 
      [1] => Mathi 
      [2] => RAvi 
     ) 

    [14288] => Array 
     (
      [0] => Karthikeyan 
     ) 

    [14291] => Array 
     (
      [0] => Mathi 
     ) 

    [14284] => Array 
     (
      [0] => RAvi 
     ) 

) 

但我需要[14289]的值如下面,

Array 
(
    [14289] => Array 
     (
      [0] => Karthikeyan 
      [1] => RAvi 
     ) 
........ 

密鑰值應爲[1]未[2]。我怎樣才能做到這一點?

回答

0

unset $example_array[14289][1]; 

$example_array[14289]= array_values($example_array[14289]);