Created
February 2, 2022 07:09
-
-
Save troke12/3053ea4ca6ad509e60525d580aae59fa to your computer and use it in GitHub Desktop.
Auto paragraph untuk gusde
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 | |
// example code | |
$text = "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. | |
It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like)."; | |
$text = str_replace("\r\n","\n",$text); | |
$paragraphs = preg_split("/[\n]{2,}/",$text); | |
foreach ($paragraphs as $key => $p) { | |
$paragraphs[$key] = "<p>".str_replace("\n","<br />",$paragraphs[$key])."</p>"; | |
} | |
$text = implode("", $paragraphs); | |
echo $text; | |
?> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>Welcome to PHPSandbox</title> | |
</head> | |
<body> | |
<?php echo $text ?> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment