2014-09-24 164 views
0

我在PHP做的代碼和我被困在一個點如果你知道任何解決方案,那麼請給我answer.What我有一個數組低於:如何重新排列陣列

Array 
(
    [0] => Array 
     (
      [0] => Array 
       (
        [Client] => Array 
         (
          [id] => 64 
          [firstname] => abc 
          [lastname] => def 
          [email] => [email protected] 
         ) 

       ) 

      [1] => Array 
       (
        [Client] => Array 
         (
          [id] => 109 
          [firstname] => Sandip 
          [lastname] => Shah 
          [email] => [email protected] 
         ) 

       ) 

     ) 

    [1] => Array 
     (
      [0] => Array 
       (
        [Client] => Array 
         (
          [id] => 120 
          [firstname] => Vandana 
          [lastname] => Mathur 
          [email] => [email protected] 
         ) 

       ) 


     ) 

    [2] => Array 
     (
      [0] => Array 
       (
        [Client] => Array 
         (
          [id] => 113 
          [firstname] => Raj 
          [lastname] => Kumar 
          [email] => [email protected] 
         ) 

       ) 

     ) 

) 

現在該怎麼辦我想要的最後一個數組如下: 有可能使用數組php函數下面的方式嗎?

Array 
(
      [0] => Array 
       (
        [Client] => Array 
         (
           [id] => 64 
           [firstname] => abc 
           [lastname] => def 
           [email] => [email protected] 
         ) 

       ) 

      [1] => Array 
       (
        [Client] => Array 
         (
          [id] => 109 
          [firstname] => Sandip 
          [lastname] => Shah 
          [email] => [email protected] 
         ) 

       ) 


      [2] => Array 
       (
        [Client] => Array 
         (
          [id] => 120 
          [firstname] => Vandana 
          [lastname] => Mathur 
          [email] => [email protected] 
         ) 

       ) 

      [3] => Array 
       (
        [Client] => Array 
         (
          [id] => 113 
          [firstname] => Raj 
          [lastname] => Kumar 
          [email] => [email protected] 
         ) 

       ) 

) 
+1

你嘗試過什麼? ['array_merge'](http://php.net/array_merge)將追加數字索引 – kero 2014-09-24 12:30:37

+0

與最新版本的PHP你可以使用參數解包與數組合並array_merge(.. $ yourArray)刪除1層的陣列 – 2014-09-24 12:33:04

回答

5

所以,你只是想合併深度2的所有數組?

很簡單:擴大大數組(通過call_user_func_array),併合並其內容:

$newArray = call_user_func_array('array_merge', $array); 
+0

感謝bwoebi它的作品!!!!! – 2014-09-24 12:36:25