I have a variable
$school_name;
It's fetching many data from the server and I want to replace comma, underscore and dash to the variable value and echo but the problem is I can't replace it Please support for fix the bug Thank you
答案 0 :(得分:3)
Use str_replace like this
$result = str_replace(array(',','-','_'), $shool_name, $yourStringFromServer);
Hope this helps.
答案 1 :(得分:2)
使用str_replace函数。
<?php
$result = "GOOD_AFTERNOON-TODAY,FINE";
$shool_name = "test";
$result = str_replace(array(',','-','_'), $shool_name, $result );
echo $result;
?>
<强>输出强>
GOODtestAFTERNOONtestTODAYtestFINE
签入编辑:Click Here
用AND替换为&amp;。
<?php
$result = "Raichand_International..and..school";
$shool_name = "&";
$result = str_replace(array('and'), $shool_name, $result );
echo $result;
?>
<强>输出强>
Raich&_International..&..school
答案 2 :(得分:0)
Try this:
str_replace(array(',','_','-'), $shool_name, $result);