Last active
March 23, 2022 16:54
-
-
Save cmd05/fe70e36523396a0e15febe4a73b2467e to your computer and use it in GitHub Desktop.
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 | |
if(isset($_POST['txt'])) { | |
$value = $_POST['txt']; | |
} | |
$newtxt = preg_replace('#\*{2}(.*?)\*{2}#', '<b>$1</b>', $value); //bold **something** | |
$newtxt = preg_replace('#\_{2}(.*?)\_{2}#', '<i>$1</i>', $newtxt); //italics __something__ | |
$newtxt = preg_replace('#\`{2}(.*?)\`{2}#', '<img src = "$1">', $newtxt); //image ``something.jpg/png`` | |
$newtxt = preg_replace('#\-{2}(.*?)\-{2}#', '<br>', $newtxt); //break line ---- | |
echo $newtxt; | |
echo "<br> Source code: " . htmlspecialchars($newtxt); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment