Use the PHP function preg_match_all () to convert the URL link address in the text to HTML code.
there is such a code in the PHP language, similar to the function of the preg_match () function, called the PHP function preg_match_all (). If third parameters are used, all possible matching results will be put in. This function returns the total number of pattern matches (possibly 0), and returns False if an error occurs.
below is an example of converting the URL link address in the text to HTML code. Code 6.4 is an example of the use of PHP function preg_match_all (). The
code 6.4 turns the link address in the text to HTML
[code].Lt;? PHP
/ / / / / / / / / / / / / input: string
/ / output: string
{> {/ > / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / input Until there is a blank,
preg_match_all (.Quot; /http:\/\/?.#91; ^\s.#93; /i.quot;
, $text, $links);
/ / / / / / / / / / / / / / / / > = 40. If more than $max_size is set, it is shortened.
$len = strlen ($link_url);
if ($len.Gt; $max_size)
$link_text = {
= {> > > {/ >} / > / / / / / / / / / / > = = Uot;
.Lt; a href='$link_url'.gt; $link_texta.gt;.Quot; $text);
}
return $text; a / > / / / / > "this is a multi line text containing multiple link addresses.
welcome access to http://www.taoboor.com;
Print url2html ($str);
/ * output result
this is a multiline literal
containing multiple URL link addresses. Welcome access to.Lt; a href='http://www.taoboor.com'.gt;
http://www.taoboor.coma.gt;
* /
?.gt; [/code]
hope that everyone can fully grasp the application of this function through the example of the use of the PHP function preg_match_all () above.