Last active
January 2, 2016 20:29
-
-
Save enderandpeter/8356802 to your computer and use it in GitHub Desktop.
Split on linebreaks and a delimiter on each line.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$thestring =<<< EOS | |
The beats: fast | |
The rhymes: bold | |
The brass: monkey | |
EOS; | |
// If this doesn't work, try the pattern /$\R?^/m | |
// Yes, that's the endline before the startline. | |
foreach(preg_split("/\r\n|\n|\r/", $thestring) as $line){ | |
$linearray = explode(':', $line); | |
echo '<b>' . $linearray[0] . '</b>: ' . $linearray[1] . '<br />'; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment