有人可以帮我找一些PHP。
原始代码〜有效,但输出顺序错误。所以我需要反转JSON数组的顺序/顺序。
<?php
$url = "https://api.typeform.com/XXX";
$json = file_get_contents($url);
$data = json_decode($json, true);
foreach ($data["responses"] as $item) {
if ($item["answers"]["textfield_14052468"] != '') {
$intitule = $item["answers"]["textfield_14052468"];
$description = $item["answers"]["textarea_14052495"];
$boite = $item["answers"]["textfield_14051470"];
$contact = $item["answers"]["textfield_14053600"];
$type = $item["answers"]["list_15488974_other"];
$contactmail = $item["answers"]["email_14053555"];
$madate = $item["answers"]["date_14052792"];
$file = $item["answers"]["fileupload_14052536"];
$contract = $item["answers"]["textarea_14052561"];
$web = $item["answers"]["website_14052525"];
$date_submit = $item["metadata"]["date_submit"];
我可以找到 array_reverse
的位置答案 0 :(得分:0)
$json = file_get_contents($url,0,null,null);
$tmp = json_decode($json, true); // using a temp variable for testing
$result = $tmp;
$result['data'] = array_reverse($result['data']);
foreach ($result['data'] as $event) {
echo '<div>'.$event['name'].'</div>'; //in order to display in div
答案 1 :(得分:0)
$url = 'http://link.to.api'
$json = file_get_contents($url,0,null,null);
$tmp = json_decode($json, true);
$result = array_reverse($tmp);
print "<pre>";
print_r($result);
print "</pre>";