- str_replace: documentation ( source)
- explode: documentation ( source)
<?php
const COMMA = ',';
const EMPTYSTR = '';
const NEWLINE_CHAR = '\n';
const ENDL = "\n";
$data = '1,2,3,\n,4,5,6,\n,7,8,9';
$strNumsEtc = str_replace( COMMA, EMPTYSTR, $data);
$strArr = explode(NEWLINE_CHAR,$strNumsEtc);
foreach ($strArr as $str) {
echo $str,ENDL;
}
echo 'Shon',"\\",NEWLINE_CHAR;