显示具有索引位置的数组


To display an array with index position using php

我有一个数组,其中有对象,并试图返回一个数组与索引位置。

我有这个数组
  Array
  (
    [id] => 174
    [timestamp] => 2016-08-25 13:08:11
   )
  Array
  (
    [id] => 161
    [timestamp] => 2016-07-21 13:27:33
   )
  Array
  (
   [id] => 160
   [timestamp] => 2016-07-21 10:35:45
  )

我想得到这样的东西:

Array
  (
 [0] => Array
    (
        [id] => 174
        [timestamp] => 2016-08-25 13:08:11                                                     
     )
 [1] => Array
    (
        [id] => 161
        [timestamp] => 2016-07-21 13:27:33
    )
 [2] => Array
    (
        [id]=> 160
        [timestamp] => 2016-07-21 10:35:45
     )
 )

是否有任何函数可以做到这一点?这是我用来显示数组

的代码
if(isset($_REQUEST['search_export'])){
    $result_array = unserialize($_REQUEST['export_arr']);
    $objRes = json_decode(json_encode($result_array), true);
    foreach ($objRes as $resarr) {
        $que_ans_val = unserialize($resarr['ques_ans']);
        $que_ans = json_decode(json_encode($que_ans_val), true);
        $resarr['ques_ans'] = implode(',',$que_ans);
        $array_first = array_splice($resarr,0,1);
        $array_middle = array_splice($resarr,0,23);
        $array_last = array_splice($resarr,0,22);
        $results =  $array_first + $array_last + $array_middle;
        echo "<pre>"; print_r($results);
    }

这是一些奇怪的代码,但它应该用我能想到的最简单的方式来做你想要的

$results[] = $array_first 
$results[] = $array_last 
$results[] = $array_middle;
echo "<pre>" . print_r($results, true) . '</pre>';

将所有数组存储在一个数组中并检索它。如:

$arr = array($array1,$array2,$array3);
print_r($arr);