# PHP: function strotolower

**URL:** <https://forum.kirupa.com/t/php-function-strotolower/219885>\
**Category:** programming\
**Created:** [March 20, 2007, 10:09pm UTC](https://forum.kirupa.com/t/php-function-strotolower/219885 "2007-03-20T22:09:40Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![LATO](https://avatars.discourse-cdn.com/v4/letter/l/f17d59/32.png) [@LATO](https://forum.kirupa.com/u/LATO)\
**Post date:** [March 20, 2007, 10:09pm UTC](https://forum.kirupa.com/t/php-function-strotolower/219885/1 "2007-03-20T22:09:40Z")

</div>

Hi,

I have a variable that equals a html page with tags and content between tags. I would like a function that makes everything between \< and the first following \> lower case.  
example: \<TABLE BORDER=“1”\>PONY\</TABLE\> to \<table border=“1”\>PONY\</table\>

I found this on [php.net](http://php.net) but it first did the opposite so I changed \< to \> and vice versa. And it seems to work… But I would like to make sure it’s good code and does exactly what I want. It’s to advanced php for me. Is preg\_slit necessary? Do I need to change the order because I switched \< and \>?

THANKS!

```php
function lowerinsidetags ($str) {
		$chars = preg_split ("//", $str);
		$tolower = true;
		$str = '';
		foreach ($chars as $k) {
		if ($k == '>') { $tolower = false; }
		if ($tolower) { $k = strtolower ($k); }
		$str .= $k;    
		if ($k == '<') { $tolower = true; }
		}
		return $str;
		}

```
