使用三元运算符的PHP-span关闭标记


$json = '[{"Number":"333567","Cost":0},{"Number":"333568","Cost":7500},{"Number":"333569","Cost":7500}]';
$options = json_decode($json, true);
foreach ($options as $key => $value) {
$newArray[$value['Number']]= $value['Number']." "."<br /> <span>".($value['Cost'] / 100 == 0 ? 'Free </span>': "&pound; </span>".$value['Cost'] / 100);
}
echo '<br>';
echo '<br>';
echo json_encode($newArray);
echo '<br>';

我只需要在成本左右添加span标签免费,价格不含编号

结束标记不会被呈现。。。

我尝试了很多东西,但坚持了下来:

$newArray[$value['Number']]= $value['Number']." "."<br /> <span>".($value['Cost'] / 100 == 0 ? 'Free' : "&pound;".($value['Cost'] / 100)."</span>");
$newArray[$value['Number']]= $value['Number']." "."<br /> <span>".($value['Cost'] / 100 == 0 ? 'Free' : "&pound;".($value['Cost'] / 100))."</span>";

相关内容

  • 没有找到相关文章

最新更新