drtzb06222 2019-07-09 11:39
浏览 129
已采纳

使用php格式化JSON到wordpress中的html [关闭]

I have an api that returns this

{
    "success": true,
    "data": {
        "medicineId": 15,
        "medicineName": " Alectinib",
        "medicineDescription": "Alectinib is a second generation oral drug that selectively inhibits the activity of anaplastic lymphoma kinase (ALK) tyrosine kinase. It is specifically used in the treatment of non-small cell lung cancer (NSCLC) expressing the ALK-EML4 (echinoderm microtubule-associated protein-like 4) fusion protein that causes proliferation of NSCLC cells. Inhibition of ALK prevents phosphorylation and subsequent downstream activation of STAT3 and AKT resulting in reduced tumour cell viability.

Approved under accelerated approval in 2015, alectinib is indicated for use in patients who have progressed on or were not tolerant of crizotinib, which is associated with the development of resistance.",
        "sideEffects": "tiredness . 
constipation . 
swelling in your hands,feet,ankles,face .
muscle pain , tenderness and weakness (myalgia) .
low red blood cell count (anemia) .",
        "chemicalFormula": "
C30H34N4O2",
        "indication": "Alectinib is a kinase inhibitor indicated for the treatment of patients with anaplastic lymphoma kinase (ALK)-positive, metastatic non-small cell lung cancer (NSCLC) who have progressed on or are intolerant to crizotinib. This indication is approved under accelerated approval based on tumor response rate and duration of response. Continued approval for this indication may be contingent upon verification and description of clinical benefit in confirmatory trials.",
        "associatedCondition": "Refractory, metastatic Non small cell lung cancer",
        "alternatives": [
            {
                "medicineId": 10,
                "medicineName": "Alclometasone"
            }
        ],
        "categories": [
            "BCRP/ABCG2 Inhibitors",
            "Antineoplastic and Immunomodulating Agents",
            " Antineoplastic Agents"
        ]
    },
    "message": "Successfully retrieved"
}

I want to format that to look good in a popup Any idea how i can do that?

  • 写回答

1条回答 默认 最新

  • douhui8163 2019-07-09 11:50
    关注

    I guess this is what you were looking for:

    <?php
    $contents = 'Your json result here';
    $jsonArray = json_decode($contents,true);
    $medicineId = $jsonArray["medicineId"];
    ?>
    
    <h1> MedicineId: <?php echo $medicineId ?> </h1>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效
  • ¥15 悬赏!微信开发者工具报错,求帮改
  • ¥20 wireshark抓不到vlan