revisa el manual de PHP
http://php.net/str_replace Edito:
si, meti la pata....
u otra técnica, es hacer uso de
preg_replace_callback() y con tu funcion de callback devolver lo justo y necesario...
Código PHP:
function foo($match)
{
static $i = 0;
return ' elemento: ' . (++$i) . '; ';
}
echo preg_replace_callback('/\[a\]/', 'foo', 'este [a] es bien [a] o no?? [a]');
lee el siguiente tema:
http://www.forosdelweb.com/f18/aport...s-pcre-646110/
suerte!