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>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 在若依框架下实现人脸识别
  • ¥15 网络科学导论,网络控制
  • ¥100 安卓tv程序连接SQLSERVER2008问题
  • ¥15 利用Sentinel-2和Landsat8做一个水库的长时序NDVI的对比,为什么Snetinel-2计算的结果最小值特别小,而Lansat8就很平均
  • ¥15 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错
  • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
  • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载
  • ¥15 c#逐行读取txt文本,但是每一行里面数据之间空格数量不同