php - replacing new line characters with coma from given text -
here have tried replace newline char comma. checked previous threads , acted accordingly still no solution.
$letters = '#\s+#'; $rep = ','; $output = str_replace($letters, $rep, trim($text)); echo $output;
link demo : http://ideone.com/dofosc
str_replace()
string replace , not regex replace. preg_replace()
should used if want regex-based replace. however, replace each new line comma using:
$output = str_replace(array("\n", "\r\n"), ",", $text);
Comments
Post a Comment