Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/6.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中的html代码_Php_String_Magento - Fatal编程技术网

替换商标符号(™) 使用php中的html代码

替换商标符号(™) 使用php中的html代码,php,string,magento,Php,String,Magento,我有以下字符串: $str='1™ 是一个商标' 现在我想把这个字符串放在一个CSV文件中,比如:“Enzyme™是一个商标”,因为如果™ 放在CSV文件中,Magento导入产品安装程序只是逃避它。有人能帮我解决这个问题吗,因为我在Google上搜索了很多,但没有找到正确的建议。对不起,我的英语不好。 我尝试了以下代码: htmlentities($db->col['title'], ENT_QUOTES | ENT_IGNORE, "UTF-8");//but it si

我有以下字符串:

$str='1™ 是一个商标'

现在我想把这个字符串放在一个CSV文件中,比如:“Enzyme™是一个商标”,因为如果™ 放在CSV文件中,Magento导入产品安装程序只是逃避它。有人能帮我解决这个问题吗,因为我在Google上搜索了很多,但没有找到正确的建议。对不起,我的英语不好。

我尝试了以下代码:

htmlentities($db->col['title'], ENT_QUOTES | ENT_IGNORE, "UTF-8");//but it simply removes '™'<br> 
htmlentities($db->col['title'], ENT_QUOTES , "UTF-8"); //removes whole string <br>
使用php中的全局函数,可以将带有“特殊字符”的字符串转换为使用html实体的字符串

$variable = "Enzyme™ is a trademark";
$convertedVariable = htmlentities($variable);
echo $convertedVariable; // echos: Enzyme&trade; is a trademark

htmlentities:@Jite我已经试过了,但没有结果如何编辑问题并添加一些代码。php>echo htmlentities'™' //⇒ &trade;这是我尝试过的,它非常有效。@mudasobwa它在php文件中工作得很好,但在将它放入CSV单元格时,它再次显示为'™'是的,但当把它放在CSV文件中时,它又像酶一样出现了™ 是否将转换后的字符串或原始字符串插入CSV文件?htmlentities函数不会更改原始值,因为它不是通过引用传递的,而是返回一个新值“fixed”字符串。@AJ..那么您可能已经这样做了。我想将相同的字符串放入CSV中,以便在导入完成后可以在html页面上很好地反映出来.但我的问题是,当它以原始值出现在CSV中时,Magento将直接转义此行: