Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * @collected by @mshannaq
- * @link https://arabia.io/php/12590
- * convert hashtag and mention
- *
- */
- if (!$_POST['submitted']){
- ?>
- <html dir="rtl" lang="ar">
- <head>
- <meta charset="UTF-8">
- </head>
- <body>
- <form method="post">
- <p>ادخل نصا مع هاشتاق ومنشن</p>
- <textarea name="text" cols="30" rows="10"></textarea>
- <input type="submit" value="هشتق">
- <input type="hidden" name="submitted" value=1>
- </form>
- </body>
- <?php
- } else {
- if ($_POST['text'] == ""){
- echo "لم تدخل نصا ، ارجع وادخل نصا";
- } else{
- echo '<html dir="rtl" lang="ar"><meta charset="UTF-8">';
- $text = $_POST['text'];
- $hashtaged = preg_replace('/#([^\s]+)/', '<a href="http://ex.com/hashtag/$1">$1</a>', $text);
- $mentioned = preg_replace('/@([^\s]+)/', '<a href="http://ex.com/user/$1">$1</a>', $hashtaged);
- echo "النص بعد ان تم تحويله الى هاشتاق ومنشن هو<hr>";
- echo $mentioned;
- echo "<hr>";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement