|
Posted by Rik on 08/08/06 16:51
Miguel Cruz wrote:
> "monomaniac21" <mcyi2mr3@googlemail.com> wrote:
>> well i figured out my own way of doing this cos the problem kept
>> bugging me and ive added her for anyone else who is interested. if
>> anyone else knows of a more efficient way id love to hear it. im not
>> sure but i think exploading a string then searching each array value
>> might be bettered by a function that just performed a search and
>> replace on the string.
>>
>> $para1 = "sdfsdf dsf dsfsd www.dsafads.com";
>> $para1_arr = explode(' ',$para1);
>> $i = 0;
>> foreach ($para1_arr as $value) {
>> $newarr[$i] = $value;
>> if (strstr($value, 'www.') != FALSE) {
>> $value = "<a href='http://$value'>$value</a>";
>> $newarr[$i] = $value;
>> }
>> $i = $i + 1;
>> }
>> $para1 = implode(' ', $para1);
>
> How will that work with mail.yahoo.com or groups.google.com ?
Not, but as the OP stated: he only wants links beginning with www.
Personally, I'd check for '|[a-z]+://|', which will find protocols, and
maybe put an extra check in for words starting with 'www.'.
Grtz,
--
Rik Wasmus
[Back to original message]
|