# PHP -\> STRTR() function problem

**URL:** https://forum.kirupa.com/t/php-strtr-function-problem/158903
**Category:** Uncategorized
**Created:** [August 12, 2005, 5:21pm UTC](https://forum.kirupa.com/t/php-strtr-function-problem/158903 "2005-08-12T17:21:08Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![bandinopla](https://avatars.discourse-cdn.com/v4/letter/b/9e8a1a/32.png) [@bandinopla](https://forum.kirupa.com/u/bandinopla)
#### Post date: [August 12, 2005, 5:21pm UTC](https://forum.kirupa.com/t/php-strtr-function-problem/158903/1 "2005-08-12T17:21:08Z")

</div>

Hi,  
I’m making a function to replace in a textbox: \*\* for \<b\> … and that kind of thing… [br] for \<br\>… etc, so somaone can write smilefaces and then I can replace that by a image [:-)] =\> 😃

my function is:

```php

function colorearTexto($str){
$RESERVED=array(" **"=>"<b>","**"=>"</b>","
"=>"<br>"); //... etc
return strtr($str, $RESERVED);
}

```

My problem is… there is a way to count the number of “[” (in this case) so if they don’t match with the numer of “]” an error sintaxis appears… bicouse if someone write:

hello \*\*my name is [/b  
… etc etc blabla

and forgot the “]”, i don’t want that all the text appears in bold…

or there is another way??
