Strict Standards: Resource ID#26 used as offset, casting to integer (26) in /home/tvoyweb/domains/tvoyweb.ru/public_html/forums/include/fm.class.php on line 401

Strict Standards: Resource ID#28 used as offset, casting to integer (28) in /home/tvoyweb/domains/tvoyweb.ru/public_html/forums/include/fm.class.php on line 401

Strict Standards: Resource ID#29 used as offset, casting to integer (29) in /home/tvoyweb/domains/tvoyweb.ru/public_html/forums/include/fm.class.php on line 401
ТвойWeb :: Версия для печати :: Подставить переменную
ТвойWeb » WebMaster класс » PHP/Perl » Подставить переменную

Страниц (1): [1]
 

1. Vladimir - 16 Сентября, 2009 - 11:29:41 - перейти к сообщению
$title = "Заголовок";
$content = "Текст";

В тексте есть рисунки, к которым нужно добавить подпись, состоящую из переменной $title.

CODE:
$content = str_replace("<img", '<img alt="" title=""', $content);


Как вставить $title в alt="" title="" ?
2. Furax - 16 Сентября, 2009 - 21:25:44 - перейти к сообщению
CODE:
$content = str_replace("<img", "<img alt=\"$title\" title=\"$title\"", $content);
Предварительно убедись, что в $title нет спецсимволов ('&', '"', '<', '>'Подмигивание - например, так:
CODE:
$title = htmlSpecialChars($title);
3. Vladimir - 18 Сентября, 2009 - 07:33:23 - перейти к сообщению
Спасибо!

Форум на AlfaSpace.NET


Powered by ExBB
ExBB FM 1.0 RC1 by TvoyWeb.ru
InvisionExBB Style converted by Markus®

[Script Execution time: 0.0341]     [ Gzipped ]