Created
August 14, 2015 06:43
-
-
Save maxkostinevich/79e4782657745ee4a654 to your computer and use it in GitHub Desktop.
Convert multi-line string to UL-list
This file contains hidden or 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 | |
/* | |
* Convert multi-line string to UL-list | |
* 1. Explode the multi-line string ($string) into array by the new line symbol ("\n") | |
* 2. Convert the array back into the string using "implode" function and append the ul and li tags. | |
*/ | |
function str_to_list($str){ | |
return '<ul><li>' .implode('</li><li>', explode("\n", $str)). '</li></ul>'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment