2011-11-02 46 views
0

我正在使用var_dump输出一个字符串,但长度不同,然后显示什么,所以我打印出每个字符,发现有隐藏的HTML代码#40;和#41;在归属于长度的字符串中。这些在sql语句中导致问题,所以我试图删除它们,但htmlspecialchars_decode和urldecode不删除字符。我如何获得这些代码?来自数据库的值是utf-8(CHARSET = utf8 COLLATE = utf8_bin),并且没有存储任何html代码(在表格中存储为“Civic(轿车)”)。在PHP字符串中显示的html代码

//this is the output of the string 
Civic (#40;sedan)#41; 
echo var_dump($data['model']).'<br>'; 

//output 
string(21) "Civic (sedan)" 

echo var_dump(strip_tags($data['model'])).'<br>'; 

//output 
string(21) "Civic (sedan)" 

echo var_dump(htmlspecialchars_decode($data['model'])).'<br>'; 

//output 
string(21) "Civic (sedan)" 

echo var_dump(urldecode($data['model'])).'<br>'; 

//output 
string(21) "Civic (sedan)" 
+0

你能不能做一个str_replace()函数; ? – TheBlackBenzKid

+0

我可以但随后我必须替换其他字符以及我不知道存储在一个数据库中的60,000条记录 –

+0

您需要替换一个海量数组,除非您知道所有情况。 preg_replace会更好 –

回答

0

html_entity_decode()是什么你之后,我想......

+0

但是,这会将“公民(#40;轿车)#41;'转换为'公民((轿车))'。但是,也许给定的输出错误输入。 – mAu

+0

html_entity_decode()做了诀窍。谢谢! –