3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str = "\r1|John|Smith|company name\r\naddress\r\nwhat they did\r\n2|Amy|Doe|company name\r"; $new = join("|",explode("\r\n",$str)); var_dump($new); $str = "\r|John|Smith|company name\r\naddress\r\nwhat they did\r\n|Amy|Doe|company name\r"; $new = join("|",explode("\r\n\t",$str)); var_dump($new);

preferences:
47.68 ms | 402 KiB | 5 Q