dshun123456 2016-01-19 08:12
浏览 136
已采纳

如何将HTML数据转换为json,php,mysql?

how to convert HTML data to json, example as below, description content how to convert as json, it is from mysql, php., how to send json responce as plain text, but description comes from the mysql db as it is, but how to send the json responce api to androind.

public function actionTestanalysis()
{
//echo $keyword=$_POST['keyword'];
    $query= Yii::app()->db->createCommand("select * from test ORDER BY id DESC")->queryAll();
    $arr = array();
    if(count($query) > 0) {

    foreach($query as $query){
    $arr[] = $query;    
    }
    }

    # JSON-encode the response
    $json_response = json_encode($arr);

    // # Return the response
    echo $json_response;


//exit;
}

json responce

[
    {
        "id": "99",
        "name": "Max-Gain on or before 25th January 2016 in Max India Limited.",
        "description": "

\tMax India Limited has announced the Record date for Three way De-Merger as 28th January 2016 (Thursday). <\/div>


\t <\/div>


\tAnyone want to Gain from the three way De-Merger of Max India Group one should buy the shares of Max India Limited on or before – 25th January 2016 (Cum-Date – Monday Tentavily) otherwise to be on safer side you can buy on or before 22nd January 2016(Friday) and get invested in it.<\/div>


\t <\/div>


\tIf any investor invests for a period Of 12 – 18 Months , this scrip will be a Multifold - Multi Bagger.<\/div>


\t <\/div>


\tTo View the full report on Max India Limited authored . <\/div>


\t <\/div>


\tPlease Click The Below Link<\/div>


\t


\t\thttp:\/\/www.test.com\/index.php\/newsOpportunities\/list\/scroll\/no-pain-all-gain-maximum-benefit-in-max-india-ltd<\/a><\/p>
<\/div>
",
        "image": "",
        "status": "unlock"


    },
  • 写回答

3条回答

      报告相同问题?

      相关推荐 更多相似问题

      悬赏问题

      • ¥20 boost电路升压频率和占空比选择
      • ¥15 找个人工智能的大佬咨询一些毕设问题
      • ¥15 需要教程:GD32F450I移植无系统lwip
      • ¥15 中文语料库检索构式 求助
      • ¥15 关于naver点击量信息
      • ¥15 Linux gcc升级问题
      • ¥100 如何封禁域名,让app打不开呢?
      • ¥15 通过安卓命令如何打开控制中心
      • ¥15 Nginx 配合Django 丢样式
      • ¥15 求问Python学生成绩管理系统的问题