0

我正在使用 jotform php api 来取回我所有的提交。响应写在下面。我想不出一种方法来解析所有数据。如何解析这个复杂的数组?

array(3) {


[0]=>
  array(9) {
    ["id"]=>
    string(18) "331530421121325001"
    ["form_id"]=>
    string(14) "53263737388365"
    ["ip"]=>
    string(13) "32.33.33.33"
    ["created_at"]=>
    string(19) "2016-02-17 10:00:07"
    ["status"]=>
    string(6) "ACTIVE"
    ["new"]=>
    string(1) "0"
    ["flag"]=>
    string(1) "0"
    ["updated_at"]=>
    string(19) "2016-02-17 10:00:17"
    ["answers"]=>
    array(1) {
      [1]=>
      array(4) {
        ["text"]=>
        string(9) "Full Name"
        ["type"]=>
        string(16) "control_fullname"
        ["answer"]=>
        array(2) {
          ["first"]=>
          string(15) "nnnasdadsaasdad"
          ["last"]=>
          string(20) "dsadsadsadsadadassda"
        }
        ["prettyFormat"]=>
        string(36) "nnnasdadsaasdad dsadsadsadsadadassda"
      }
    }
  }
 }

这是我的代码,但到目前为止还没有那么成功。

$responses=$jotformAPI->getSubmissions();
    foreach ($responses as $response) {
          //print_r($response);
          foreach($response as $element=>$value)
          {
            echo $value;
            if(is_array($value))
            {
                foreach($value as $val)
                {
                    echo $val;
                }
            }
          }
    }

请帮忙。

4

1 回答 1

0
$p[0]=  array(
    "id"=>"331530421121325001",
    "form_id"=>  "53263737388365",
    "ip"=>"32.33.33.33",
    "created_at"=>"2016-02-17 10:00:07",
    "status"=>"ACTIVE",
    "new"=>"0",
    "flag"=>"0",
    "updated_at"=> "2016-02-17 10:00:17",
    "answers"=> array(
     1=>array("text"=> "Full Name",
        "type"=>"control_fullname",
        "answer"=>array(
          "first"=>"nnnasdadsaasdad",
          "last"=> "dsadsadsadsadadassda"
        ),
     "prettyFormat"=> "nnnasdadsaasdad dsadsadsadsadadassda",
      )));

我使用递归函数解决了

ra($p);
 function  ra($p){
  foreach($p as $key=>$value) :
    $p=$value;
    if(is_array($p)) {
         ra($p);
    }else{
    echo "<br>",$value;
    }

    endforeach; 
 }
于 2016-02-17T17:48:51.437 回答