PHP:反转 JSON 数组



有人可以帮我一些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的位置

$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>";

相关内容

  • 没有找到相关文章

最新更新