how to convert to small caps

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mramardeeepsingh
Forum Newbie
Posts: 5
Joined: Wed Dec 13, 2006 2:05 pm

how to convert to small caps

Post by mramardeeepsingh »

hi friends
i want to know that how can i replace the entire content in <..............> tags.

for example
i have a code
<STRONG><I><B><FONT COLOR="red">Example Text</FONT></B></I></STRONG>

and i want to convert the html tags to small caps without converting the text i.e Example Text.

<STRONG> should be <strong>
<I> should be
<FONT COLOR="red"> should be <font color="red">

but keeping the text i.e Example Text intact.
due to which i can't use strtolower.

please tell me how to convert the html tags into smallcaps.
what regular expression to use so that i get

<strong><font color="red"><b>Example Text</b></font></strong>

in simple words i want html tags to be converted to small caps, remaining the text intact.

please help
User avatar
Nathaniel
Forum Contributor
Posts: 396
Joined: Wed Aug 31, 2005 5:58 pm
Location: Arkansas, USA

Post by Nathaniel »

You'll want to use preg_replace.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

I'd recommend preg_replace_callback() over preg_replace(). Security concern..
mramardeeepsingh
Forum Newbie
Posts: 5
Joined: Wed Dec 13, 2006 2:05 pm

can u provide me the code

Post by mramardeeepsingh »

can you provide me the code for the same.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

What have you tried? Have you searched our forum? We have had examples of doing similar things...
mramardeeepsingh
Forum Newbie
Posts: 5
Joined: Wed Dec 13, 2006 2:05 pm

Post by mramardeeepsingh »

i havent tried anything yet.
i am a newbie.
just got around preg_replace.

can u provide the code
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

I will not just provide the code without some effort seen on your part.
mramardeeepsingh
Forum Newbie
Posts: 5
Joined: Wed Dec 13, 2006 2:05 pm

Post by mramardeeepsingh »

i said i am a newbie.
i dont have any idea how to do that.

if i was aware, then i wont be posting on the forum.

anyways if dont want to help, then its ok.
never mind.

thanks
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

We are here for you to learn, not do the work for you. If you don't want to attempt to figure it out, then I suggest you search for similar threads.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

If you want to learn about regular expressions start with http://www.regular-expressions.info/tutorial.html
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Or you could read the manual for preg_replace_callback() and preg_replace(). Seriously though, very few people here are going to write your code for you. At the very least, give it a shot. If what you try fails, post your code so we can see what you are doing and help walk you through it. A lot of us here are more than happy to help you figure your problems out. But, like I said, few of us will actually solve your problems for you.
mramardeeepsingh
Forum Newbie
Posts: 5
Joined: Wed Dec 13, 2006 2:05 pm

Post by mramardeeepsingh »

thanks for the help buddy.
i will study regular expressions.

thanks man.
Post Reply