ELLIOTT,KATHERINE A (HP-FtCollins,ex1) wrote:
OK, so I've gotten NO responses to my query below so I
thought I'd ask for something slightly different and see what
I get.
if you want to get a reply

1) look in the manual/ archives first

2) use a helpful subject line
eg making links clickable

3) show us the code
you have tried to get it working - and this code will help greatly in explaining what you are trying to do

4) show us the error message OR show us the output
and explain what is wrong with it


remember - you aren't paying for this - there are hundreds of messages a day - personally I only skim read most of them - and if a question makes little sense I'm not going to spend time on it.


that said

<?php

$text = "This is a test. It is only a test.
What happens when I include a URL in my results text?

http://not.a.real.url/programs

This is only a test";

$clickable_text = preg_replace("#(http://[^\s]+)#i",
"<a href=\"$1\">$1</a>", $text);

echo $clickable_text;

?>

I haven't been particularly strict with the allowed url charecters - I've just allowed everything and assumed that the url ends with whitespace (or end of file)

Sean



If I have a bunch of plain text data, how can I pull out the
strings containing "http".  I've tried several different things
but what I end up with is more or less than what I want.
Once I have this, I can add the URL code and replace the
string but I haven't figured out how to do this.

For example, what would I do if my text looks like this (not
including the astrices):

******************************************************
This is a test.  It is only a test.
What happens when I include a URL in my results text?

http://not.a.real.url/programs

This is only a test
******************************************************

Anyone?  Anyone?

Thanks,

Katherine

-----Original Message-----
From: ELLIOTT,KATHERINE A (HP-FtCollins,ex1)
[mailto:[EMAIL PROTECTED]]
Sent: Tuesday, January 07, 2003 2:36 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Adding HTTP URL Code


Hello,

I have a string of data that can be anywhere from one line (a single URL)
to many, many lines.  The data is in plain text but, as I alluded, may
contain
one or more URLs (or none).  I then take this data and put it on a web page
so I would like to make any URLs in the data live.  Has anyone on the list
done
this?  If so, can you tell me how?  I'm stumped.

Thanks,

Katherine



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to