[ Поиск ] - [ Пользователи ] - [ Календарь ]
Полная Версия: Как выделить текст из строки ?
Oggy
Здравствуйте. В переменной $text хранится кучя текста. Как подсветить конкретные слова ? например '(ah-sah-ee)';

$lookingFor = "(ah-sah-ee)";
$text = "Acai (Euterpe olereacea), pronounced (ah-sah-ee) is a fruit that grows on the Acai Palm Trees in the Amazonian Rainforest of Brazil.";

Должно быть так:
"Acai (Euterpe olereacea), pronounced (ah-sah-ee) is a fruit that grows on the Acai Palm Trees in the Amazonian Rainforest of Brazil.";
Adil
С регулярками можно гибче, а по простому:
$lookingFor = array('(ah-sah-ee)' => '<b>(ah-sah-ee)</b>');
$text = "Acai (Euterpe olereacea), pronounced (ah-sah-ee) is a fruit that grows on the Acai Palm Trees in the Amazonian Rainforest of Brazil.";

echo strtr($text , $lookingFor);
Быстрый ответ:

 Графические смайлики |  Показывать подпись
Здесь расположена полная версия этой страницы.
Invision Power Board © 2001-2024 Invision Power Services, Inc.