For example, if the network address we provide is httt: www.zhutiai.com, but we can use the following program to automatically add a super connection to it. Let's look at a php advanced approach. for example, if we provide the network address httt: www. ph...
For example, if the network address we provide is httt: // www.zhutiai.com, but we can use the following program to automatically add a super connection to it.
Provides an advanced php practice.
For example, if the network address we provide is httt: // www.phprm.com, but we can use the following program to automatically add a super connection to it.
Provides an advanced php Tutorial.
function autolink($foo) {$foo = eregi_replace('(((f|ht){1}tp://)[-a-za-z0-9@:%_+.~#?&//=]+)', '1', $foo);if( strpos($foo, "http") === false ){$foo = eregi_replace('(www.[-a-za-z0-9@:%_+.~#?&//=]+)', '1', $foo);}else{$foo = eregi_replace('([[:space:]()[{}])(www.[-a-za-z0-9@:%_+.~#?&//=]+)', '12', $foo);}return $foo; }$str = 'http://'; echo autolink($str);
For more details, see: http://www.phprm.com/wy/js-ajax/33810.htm
The following is a simple practice:
Function showtext ($ text) {$ search = array ('| (http: // [^] +) |', '| (https Tutorial: // [^] +) | ',' | (www. [^] +) | '); $ replace = array (' $ 1', '$ 1',' $ 1'); $ text = preg_replace ($ search, $ replace, $ text); return $ text ;}
Permanent link:
Reprint at will! Include the article address.