Auto Hyperlink from text file

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

chemaster
New php-forum User
New php-forum User
Posts: 3
Joined: Fri Oct 25, 2002 4:54 am

Auto Hyperlink from text file

Postby chemaster » Sun Nov 10, 2002 9:31 pm

Ok .... I didn't receive a reply for paid help :( so I started the project. :) Actually the project isn't so bad. .... so far

How do you retrieve a plain text file (for a html text area) and have it automatically create hyperlinks for url's and email? If possible please have it based off the below code which works well with retrieving the file and adding <BR> for returns:

<?php print nl2br(implode('', file($MyPath.'text1.txt'))); ?>

NOTE: The reason for the above code: I'm using preformatted text to maintain basic list style and need the <BR> added to maintain returns for long lines.

... I forgot, also what is the best way of insuring that harmful <tags> will not be used with the code?

Many Thanks,

Steve

User avatar
Oleg Butuzov
Last Samuray
Last Samuray
Posts: 831
Joined: Sun Jun 02, 2002 3:09 am

Postby Oleg Butuzov » Sun Nov 10, 2002 9:57 pm

Dear Steve,

One monthe ago I wark at tha project like in your project , BUT...
I needs knolege that i did not have that day, sorry...

Creat a html file with this content and you will see a result...
<TEXTAREA><a href=http://www.somelink.com>Somelink</a></TEXTAREA>


Without ActivX you can not do good editor for your custumers, you can just enter formated html and just after that you you can use it...

chemaster
New php-forum User
New php-forum User
Posts: 3
Joined: Fri Oct 25, 2002 4:54 am

What

Postby chemaster » Mon Nov 11, 2002 4:50 am

.... what?

Did you read my post?

User avatar
Oleg Butuzov
Last Samuray
Last Samuray
Posts: 831
Joined: Sun Jun 02, 2002 3:09 am

Postby Oleg Butuzov » Tue Nov 12, 2002 6:17 am

sorry , my English not so good. (it is not native language for me)

Are you want to replase all \n\r at <br> ?

if yes than...

Code: Select all

<form method="post" action="text.php">
  <textarea name="text">
<?php

$text = $HTTP_POST_VARS["text"];
$text = ereg_replace("\r\n|\r|\n","<br>",$text);

echo $text;

?>

  </textarea>
  <input type="submit">
</form>


Return to “PHP coding => General”

Who is online

Users browsing this forum: Bing [Bot] and 3 guests