Re: Emphasizing first letter of string?
| From: | Arpad Ray | Date: | Tue, 22 Aug 2006 10:50:24 +0000 |
| Subject: | Re: Emphasizing first letter of string? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-240980@lists.php.net to get a copy of this message | ||
<?php
foreach ($strings as $key => $string) {
$strings[$key] = '<em>' . $string[0] . '</em>' . substr($string, 1);
}
?>
Micky Hulse wrote:
Hi, It is getting late, and I do not think I am thinking clearly... What would be the best way to wrap <em></em> tag around the first letter of a string? I know it has to be a combination of str_replace() and substr(), but due to my level of sleepiness I am having a lot of trouble working this one out... Basically, if a config variable == true I want my script to loop through an array of strings and emphasize the first letter of each string. Make sense? Sorry, I am pretty sleepy... Hmmm, I am betting I will discover the answer as soon as I send this email. :D Anyway, any help would be great! Cheers, Micky