SHARE
TWEET

convert hashtag and mention

mshannaq Aug 23rd, 2014 289 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. /**
  3.  * @collected by @mshannaq
  4.  * @link https://arabia.io/php/12590
  5.  * convert hashtag and mention
  6.  *
  7.  */
  8.  
  9. if (!$_POST['submitted']){
  10.    ?>
  11. <html dir="rtl" lang="ar">
  12.     <head>
  13.     <meta charset="UTF-8">
  14.     </head>
  15.     <body>
  16.         <form method="post">
  17.             <p>ادخل نصا مع هاشتاق ومنشن</p>
  18.             <textarea name="text" cols="30" rows="10"></textarea>
  19.             <input type="submit" value="هشتق">
  20.             <input type="hidden" name="submitted" value=1>
  21.         </form>        
  22.     </body>
  23.     <?php
  24. } else {
  25.     if ($_POST['text'] == ""){
  26.         echo "لم تدخل نصا ، ارجع وادخل نصا";
  27.     } else{
  28.         echo '<html dir="rtl" lang="ar"><meta charset="UTF-8">';
  29.         $text = $_POST['text'];
  30.         $hashtaged = preg_replace('/#([^\s]+)/', '<a href="http://ex.com/hashtag/$1">$1</a>', $text);
  31.         $mentioned = preg_replace('/@([^\s]+)/', '<a href="http://ex.com/user/$1">$1</a>', $hashtaged);
  32.         echo "النص بعد ان تم تحويله الى هاشتاق ومنشن هو<hr>";
  33.         echo $mentioned;
  34.         echo "<hr>";
  35.     }
  36. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top