Re: [GENERAL-BG] Re: zamestvane v string
[email protected] ("Kiril Kapustin") Sun, 8 Jun 2003 13:22:15 +0300
| Newsgroups | php.general.bg |
|---|---|
| Message-ID | <001701c32da7$e9a5a040$a2474850@cucka> |
10x, Kouber!!
Tochno takova neshto mi triabvashe.
Testvah funkciata i vidiah che raboti perfektno, s izkluchenie na sluchaite
kato tozi:
<?php
$substitutions = array("obraz"=>"http://www.dir.bg",
"obrazovanie"=>"http://www.hit.bg", "obrazova"=>"http://www.mail.bg");
$text = "Ivan Popow e golqm obraz. Ima vishe obrazovanie i moje da
\"obrazova\" vsekigo. Toj e obrazuval specialna zona za tova. Pishete mu na
adres: [email protected] ili pogledneta stranicata mu na adres
www.obrazovanie.com";
foreach ($substitutions as $key=>$value)
{
$text = preg_replace("/(\W)(".$key.")(\W)/", "$1<a
href=\"$value\">$2</a>$3", $text);
}
echo $text;
?>
tyj kato puskam i eto tazi funkcia syshto po stringa, neshtata leko se
"pomazvat" :-((((
function make_clickable($text)
{
$ret = " " . $text;
$ret =
preg_replace("#([\n ])([a-z]+?)://([a-z0-9\-\.,\?!%\*_\#:;~\\&$@\/=\+]+)#i",
"\\1<a class=\"h\" href=\"\\2://\\3\" target=\"_blank\">\\2://\\3</a>",
$ret);
$ret =
preg_replace("#([\n ])www\.([a-z0-9\-]+)\.([a-z0-9\-.\~]+)((?:/[a-z0-9\-\.,\
?!%\*_\#:;~\\&$@\/=\+]*)?)#i", "\\1<a class=\"h\"
href=\"http://www.\\2.\\3\\4\" target=\"_blank\">www.\\2.\\3\\4</a>", $ret);
$ret =
preg_replace("#([\n ])([a-z0-9\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)?[\w]+)#i",
"\\1<a class=\"h\" href=\"mailto:\\2@\\3\">\\2@\\3</a>", $ret);
$ret = substr($ret, 1);
return($ret);
}
Ako ima nachin da se "nakara" preg_match da NE zamestva, kogato kluchovata
duma zapochva sys simvola @ , mislia che vsichko shte e ok.
naprimer:
[email protected]
[email protected]
http://[email protected]
----- Original Message -----
From: "Kouber Saparev" <[email protected]>
To: <[email protected]>
Sent: Friday, June 06, 2003 2:45 PM
Subject: [GENERAL-BG] Re: zamestvane v string
> <?
> $substitutions = array("obraz"=>"http://www.dir.bg",
> "obrazovanie"=>"http://www.hit.bg", "obrazova"=>"http://www.mail.bg");
> $text = "Ivan Popow e golqm obraz. Ima vishe obrazovanie i moje da
> \"obrazova\" vsekigo. Toj e obrazuval specialna zona za tova.";
>
> foreach ($substitutions as $key=>$value) {
> $text = preg_replace("/(\W)(".$key.")(\W)/", "$1<a
> href=\"$value\">$2</a>$3", $text);
> }
>
> echo $text;
> ?>
>
> $substitutions moje da ti bude i vuv format vurnat ot
> mysql_fetch_array()...pishi ako ne se orientirash. ;-)
>
> K.
>
>
>
> --
> Bulgarian General User List Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>