Re: Change case of HTML tags

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Daniel Brown wrote:
> On Dec 19, 2007 4:10 PM, Christoph Boget <christoph.boget@xxxxxxxxx> wrote:
>> I've been looking through the docs but haven't found an internal function
>> that does what I'm looking for.  Perhaps I missed it?  Or perhaps someone
>> can point me in the right direction?  I'm looking for a routine that will
>> convert tags to lower case.  For example, if I have
>>
>> <HTML>
>>   <HEAD>
>>     <TITLE>This is the Page Title</TITLE>
>>   </HEAD>
>>   <Body>
>>     Here is the Page Text
>>   </Body>
>> </HTML>
>>
>> I want to convert only the tags to lower case.  So <HTML> becomes <html> and
>> so on; I don't want anything else touched.  This may seem kind of silly but
>> I'm working with an XMLDocument object in javascript and when I serialize it
>> to string format, for some reason all the tags are made into uppercase.  I'm
>> taking the serialized string, posting it back to the server and using it on
>> the back end.  I figure that since I can make it so that the serialized
>> string is lower case on the front end, perhaps I can convert it on the back.
>>
>> Any ideas/pointers?
>>
>> thnx,
>> Christoph
>>
> 
> 
> <?
> $s = <<<EOD
> <HTML>
>  <HEAD>
>    <TITLE>This is the Page Title</TITLE>
>  </HEAD>
>  <Body>
>    Here is the Page Text
>  </Body>
> </HTML>
> EOD;
> 
> $s = preg_replace('/<(.*)>/Ue',"strtolower('<$1>')",$s);

Nice use of the 'e' modifier, but would it not be safer to use this?

	$s = preg_replace('/<(.*)>/U', strtolower("<$1>"), $s);

This way the arbitrary html is not executed?

> 
> echo $s."\n";
> ?>
> 
> 


-- 
Jim Lucas

   "Some men are born to greatness, some achieve greatness,
       and some have greatness thrust upon them."

Twelfth Night, Act II, Scene V
    by William Shakespeare

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux