From <url> to <a> link


$inputText="<url></url> and <url></url> are 
my favorite sites."

$urlProcess_inputText= $urlProcess(inputText);

[b]target value of $$urlProcess_inputText[/b]

<a href=""></a> and 
<a href=""></a> are 
my favorite sites.

I like to change from <url> to <a> link like the above.

I guess the following is needed for it.

(1) count the number of "<url>" : 2 
<? strlen($inputText)-strlen(str_ireplace("<url>","<url",$inputText) ); ?>

(2) seperate the url value : www. and
(3) loop the myText 2 times : ~
and so forth.

Can I make it with your help?

With limited knowledge of regex :slight_smile:

$inputText="<url></url> and <url></url> are 
my favorite sites.";
echo preg_replace('/<url>(.*?)<\\/url>/s', '<a href="http://$1">$1</a>', $inputText);

Thank you, it works fine.