Re: Emphasizing first letter of string?

From: Date: Tue, 22 Aug 2006 10:56:54 +0000
Subject: Re: Emphasizing first letter of string?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-240981@lists.php.net to get a copy of this message
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! It sounds like you really need some sleep. $string = "hello world"; echo "<em>".$string{0}."</em>".substr($string, 1); David

« previous php.general (#240981) next »