2017-08-31 99 views
1

我试图让我的数组留在这个结构:修改阵列结构

array 
(
    0 => array (
     "url"=> "http://localhost/theme/wp-content/uploads/2017/08/img2.png" 
     "caption"=> "title text test" 
    ) 
) 

目前我的数组是这样的:

array 
( 
    "url" => "http://localhost/theme/wp-content/uploads/2017/08/065.jpg" 
    "caption" => "test other capition" 
) 

我想加入这两个阵列

$first = array(); 
$NewArray = array($first, $urlsCaptions); 

输出:

array( 
    0 => array(), 
    1 => array(
    "url" => "http://localhost/theme/wp-content/uploads/2017/08/065.jpg" 
    "caption" => "test other capition" 
    ) 
) 

如何正确创建数组,结构与我的问题的第一个数组完全相同?

+7

试试这个'$ NewArray =阵列($ urlsCaptions);' –

+0

@SahilGulati大,即工作。 – Gislef

+0

欢迎朋友... :) –

回答

0

试试这个:

$arr = array ($originalArray);