php-general | 2005051
Date: 05/11/05
- Next message: AC: "[PHP] Re: marking words bold"
- Previous message: tg-php <email protected>: "Re: [PHP] expand array into function arguments?"
- In reply to: tg-php <email protected>: "Re: [PHP] str_replace on words?"
- Next in thread: James E Hicks III: "Re: [PHP] str_replace on words?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
I whipped this together, it should work ok. You'll want to clean it up,
but you get the gist.
<?php
/* AC Was here */
$str="I'm going to the store to buy some stuff.";
$bold=array("store","some","stuff");
function boldWord($str,$bold) {
if(isset($str)) {
foreach($bold as $b) {
echo "$b should be <b>$b</b>\n";
$str = eregi_replace($b,"<b>$b</b>",$str);
}
$string=$str;
return $string;
} else {
$string='The inputed variable $str was empty.';
return $string;
}
} // End function bracket
// Example usage
if(isset($str)) {
$string=boldWord($str,$bold);
echo "Original: $str \n";
echo "New: $string\n";
} else {
echo "Variable str not set.";
}
?>
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
- Next message: AC: "[PHP] Re: marking words bold"
- Previous message: tg-php <email protected>: "Re: [PHP] expand array into function arguments?"
- In reply to: tg-php <email protected>: "Re: [PHP] str_replace on words?"
- Next in thread: James E Hicks III: "Re: [PHP] str_replace on words?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

