Loading ...
Sorry, an error occurred while loading the content.

Is it better solution to add hyper link in text post?

Expand Messages
  • Reazaul Karim
    Is it better solution that i am trying to?
    Message 1 of 3 , Nov 24, 2010
    • 0 Attachment
      Is it better solution that i am trying to?

      <?php
      $test = "Hellow world [www.yahoo.com] Test [http://www.google.com] Test mail [reasulk@...]";
      $data = preg_split("/\[|\]/",$test);
      $text = "";
      foreach($data as $val){
      if(preg_match('/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/i',$val)){
      $val = "<a href=\"mailto:{$val}\">{$val}</a>";
      }
      else if(preg_match('|^http(s)?://[a-z0-9-]+(.[a-z0-9-]+)*(:[0-9]+)?(/.*)?$|i', $val)){
      $val = "<a href=\"{$val}\" target=\"_blank\">{$val}</a>";
      }
      $text .= $val;
      }
      echo $text;
      ?>
    • Reazaul Karim
      Sorry! Some part is replaced. It should be like this: $test = Hellow world [www.yahoo.com] Test [http://www.google.com] Test mail [reasulk@example.com] ;
      Message 2 of 3 , Nov 24, 2010
      • 0 Attachment
        Sorry! Some part is replaced. It should be like this:

        $test = "Hellow world [www.yahoo.com] Test [http://www.google.com] Test mail [reasulk@...]";
      • Anjan Bhowmik
        It depends on your situation :) If the text is something similar to forum post, you may want to or may not, depending on whether the forum admin wants contents
        Message 3 of 3 , Nov 24, 2010
        • 0 Attachment
          It depends on your situation :)

          If the text is something similar to forum post, you may want to or may not, depending on whether the forum admin wants contents to be links on their forum.

          Also, if you are doing it for emails, i think u can leave that out as many email clients automatically do that for you.

          And finally if the text u r processing is to be edited again, u need to provide an html editor to edit the contents.

          And, if you are doing this on the fly, it might require a good bit of processing power.

          So, all things considered, i think its better to leave the links in text, unless u r forced to do otherwise.

          Thanks,
          Anjan

          On Wed, Nov 24, 2010 at 3:06 PM, Reazaul Karim <reazulk@...> wrote:
           

          Is it better solution that i am trying to?

          <?php
          $test = "Hellow world [www.yahoo.com] Test [http://www.google.com] Test mail [reasulk@...]";
          $data = preg_split("/\[|\]/",$test);
          $text = "";
          foreach($data as $val){
          if(preg_match('/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/i',$val)){
          $val = "<a href=\"mailto:{$val}\">{$val}</a>";
          }
          else if(preg_match('|^http(s)?://[a-z0-9-]+(.[a-z0-9-]+)*(:[0-9]+)?(/.*)?$|i', $val)){
          $val = "<a href=\"{$val}\" target=\"_blank\">{$val}</a>";
          }
          $text .= $val;
          }
          echo $text;
          ?>




          --
          Anjan Bhowmik
          Software & Web Development Department
          Ultra Soft
          Mobile : +8801670556419,+8801673636742
          Email : anjan011@...,info@...
        Your message has been successfully submitted and would be delivered to recipients shortly.