修改数组结构

时间:2017-08-31 17:04:42

标签: php arrays

我试图让我的阵列留在这个结构中:

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"
     )
 )

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

1 个答案:

答案 0 :(得分:0)

试试这个:

$arr = array ($originalArray);