dptj13337 2015-01-16 11:57
浏览 813
已采纳

从json更改字符串颜色[关闭]

I have a json file that looks like this

[{
"name":"P90 | Asiimov (Field-Tested)",
"url":"http:\/\/steamcommunity.com\/market\/listings\/730\/P90%20%7C%20Asiimov%20%28Field-Tested%29\"id=\"resultlink_0",
"price":"<span style=\"color:white\">8.35 USD<\/span>
","image":"http:\/\/steamcommunity-a.akamaihd.net\/economy\/image\/fWFc82js0fmoRAP-qOIPu5THSWqfSmTELLqcUywGkijVjZYMUrsm1j-9xgEObwgfEh_nvjlWhNzZCveCDfIBj98xqodQ2CZknz5rbbOKMyJYYl2STKFNVfw3-x7TBCI24dJuGoOy8-0EKgrv5YaVMbgkOIpJTcbSU_OFYwuo7UIxg_JafJCMqXvqjn_3ejBdkE3axU4\/62fx62f",
"quantity":"71",
"game":"Counter-Strike: Global Offensive"
}] 

...

When i want to diplay it i use this code

...

<tr>
<td><?php echo $data->name; ?></td>
<td><img src="<?php echo $data->image; ?>" /></td>
<td><?php echo $data->game; ?></td>
<td style="background:black"><?php echo $data->price; ?></td>
<td><?php echo (int)str_replace(',','',$data->quantity); ?></td>
<td><a target="blank" href="<?php echo $data->url; ?>">Buy</a></td>
</tr>

...

Now the problem is that the color of price is always white, i tryed to change the style of table but color is not changeing.

Any ideas?

  • 写回答

2条回答 默认 最新

  • doutui7955 2015-01-16 12:06
    关注

    The string you are echoing contains colors in it for some reason. Just remove them first using php strip_tags() function.

    <td style="background:black"><?php echo (strip_tags($data->price)); ?></td>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探