Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/245.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
尝试在PHP中使用字符串替换函数但不起作用_Php_Str Replace - Fatal编程技术网

尝试在PHP中使用字符串替换函数但不起作用

尝试在PHP中使用字符串替换函数但不起作用,php,str-replace,Php,Str Replace,我有一个名为$info['order-total']的变量,它包含一些html,其中包含字符串'Delivery'和'Collection'。我试图用字符串“卡费”替换这些。下面是我试图实现这一点的代码。我希望有人能帮我,我是初学者,谢谢: <?php $total = str_replace("Delivery", "Card Charge", $info['order_total']); $total = str_replace("Collection", "Card Char

我有一个名为$info['order-total']的变量,它包含一些html,其中包含字符串'Delivery'和'Collection'。我试图用字符串“卡费”替换这些。下面是我试图实现这一点的代码。我希望有人能帮我,我是初学者,谢谢:

<?php
  $total = str_replace("Delivery", "Card Charge", $info['order_total']);
  $total = str_replace("Collection", "Card Charge", $info['order_total']);
  print $total;

?>
试试这个:

<?php
  $total = str_replace("Delivery", "Card Charge", $info['order_total']);
  $total = str_replace("Collection", "Card Charge", $total);
  print $total;
?>