|
|
|
|
|
для: icq677555
(01.10.2009 в 14:54)
| | Второе выражение поправьте следующим образом
<?php
$pattern = "|<a href=['\"]([^'\"]+?)['\"]|is";
?>
|
| |
|
|
|
|
|
|
|
для: icq677555
(01.10.2009 в 14:45)
| | Хм.. Рановато я обрадовался..
Попробуйте например сделать $string = file_get_contents("http://wab.ru");
Получается, что не все ссылки обрабатывает..
Cheops, выручайте.. | |
|
|
|
|
|
|
|
для: cheops
(01.10.2009 в 12:57)
| | Благодарю. То что надо!
Единственное, добавил немного:
$pattern = "|<a.*?href=['\"]([^']+?)['\"].*?>|is";
|
| |
|
|
|
|
|
|
|
для: icq677555
(01.10.2009 в 09:28)
| | Можно поступить как-то так
<?php
$my = 'http://test1.com/';
$string = "test text <a href='http://site.com/about.html'>about</a> more text ".
"<a href='http://test.com/test/news.html'>news</a> more more text ".
"<a href='hell/hell.html'>hell</a>";
$pattern = "|(http://[^/]+)/|is";
$string = preg_replace($pattern, $my, $string);
$pattern = "|<a href='([^']+?)'>|is";
$string = preg_replace_callback($pattern, "replace", $string);
echo htmlspecialchars($string);
function replace($out)
{
global $my;
if(strpos($out[1], "http://") === false) return "<a href='{$my}$out[1]'>";
else return "<a href='$out[1]'>";
}
?>
|
| |
|
|
|
|
|
|
| допустим есть строка:
<?
$my = 'http://test1.com';
$string = "test text <a href='http://site.com/about.html'>about</a> more text <a href='http://test.com/test/news.html'>news</a> more more text <a href='hell/hell.html'>hell</a>";
?>
|
Как сделать, чтобы все адреса в таких ссылках заменились на нужные мне? т.е. на http://test1.com/about.html, http://test1.com/test/news.html, http://test1.com/hell/html
? | |
|
|
|
|