且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

PHP str_replace 无法正常工作

更新时间:2023-02-05 21:01:46

为了扩展 Waage 的响应,您可以使用数组来替换两组字符

To expand on Waage's response, you could use an array to replace both sets of characters

$teams = str_replace(array("\r\n", "\n"),",",$teams);
echo $teams;

这应该可以正确处理这两个项目,因为单个 \n 是有效的,如果您只是替换 \r\n

This should handle both items properly, as a single \n is valid and would not get caught if you were just replacing \r\n