doubu1853 2016-10-14 08:14
浏览 88
已采纳

Filemaker php api:将每个循环变量编码为json

I've been asked to provide filemaker data as json objects through the filemaker php api.

I've been able to use the following on a single record

 echo json_encode(array($namefamily, $namefirst, $dob, ));

Now I need to encode to json in my for each loop - not sure how to get it to work with concatenated variables in:

$records = $result->getRecords();
foreach($records as $record){
    echo' ' . $record->getField('NameFirst') . ' | ' . $record->getField('NameFamily') .' ';
}
  • 写回答

2条回答 默认 最新

  • dongmeng2687 2016-10-16 15:09
    关注

    Similar to previous answer, but using working FileMaker API syntax...

    $records = $result->getRecords();
    
    foreach($records as $record){
        $data[] = array( 
                        'NameFirst' => $record->getField("NameFirst"),
                        'NameFamily' => $record->getField("NameFamily")
                       );
    }
    
    echo json_encode($data);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?