【问题标题】:I want insert new value in json which get from sql我想在从 sql 获取的 json 中插入新值
【发布时间】:2021-08-05 19:14:59
【问题描述】:
$query2 = "SELECT distinct
                n.id AS 'channel_id',
                n.category_id,
                n.channel_name,
                n.channel_image,
                n.channel_url AS 'channel_url',
                n.channel_description,
                n.channel_type,
                n.video_id,
                c.category_name
            FROM
                tbl_channel n,
                tbl_category c

            WHERE
                n.category_id = c.cid AND c.cid = '$id' 
            ORDER BY n.id DESC 
            LIMIT $limit OFFSET $offset";
    ";

我想在频道 url 中插入新值

例如:我得到了输出 channel_url: https://edge.okezone.com/live/life.m3u8 但在这里我想在 url 末尾插入一个新值

【问题讨论】:

  • 您要插入什么新值?只需使用字符串连接:$row['channel_url'] . $new_value

标签: php mysql json api


【解决方案1】:

你可以只连接输出

$row['channel_url'] .= "new value";

【讨论】:

  • 我想在 URL 的末尾插入 $tok="&token=2alsh123" $row['channel_url'] .= "new value";这行不通
  • 你可以将$tok添加到channel_url元素$row['channel_url'] .= $tok
  • @akashefrathefrath https://edge.okezone.com/live/life.m3u8&token=2alsh123 是无效的 URL,& 应该是 ?: https://edge.okezone.com/live/life.m3u8?token=2alsh123
猜你喜欢
  • 1970-01-01
  • 2018-04-10
  • 2012-06-06
  • 2018-12-08
  • 1970-01-01
  • 1970-01-01
  • 2016-01-27
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多