我有一个名为$array
的PHP变量,它会输出类似的字母
"...", "...", "...", "...", ...
时的echo
但...
可能会包含某些字符,例如"
,,
和空格,甚至可能包含", "
如何将其更改为数组([0] => ... [1] => ... [2] => ... [3] => ... etc)
?
答案 0 :(得分:0)
PHP explode
$array = explode(",",$array); // split the string into an array([0] => '"..."', etc)
foreach ($array as $entry) {
// clean up the strings as needed
}
答案 1 :(得分:-1)
您可以使用str_replace函数:
$str = "....'...,,,";
$unwantedChars = array("'", ",");
$cleanString = str_replace($unwantedChars, "",$str);
echo $cleanString;
您可以在您想要的unwantedChar数组中添加任意数量的字符