# PHP str\_replace()

**URL:** <https://forum.kirupa.com/t/php-str-replace/52217>\
**Category:** programming\
**Created:** [May 21, 2004, 2:43am UTC](https://forum.kirupa.com/t/php-str-replace/52217 "2004-05-21T02:43:42Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ironikart](https://avatars.discourse-cdn.com/v4/letter/i/7feea3/32.png) [@ironikart](https://forum.kirupa.com/u/ironikart)\
**Post date:** [May 21, 2004, 2:43am UTC](https://forum.kirupa.com/t/php-str-replace/52217/1 "2004-05-21T02:43:42Z")

</div>

Does anyone know if this function can return an internal counter to find out how many times a replacement has been done?

I have a suspicion it doesn’t so I’ll probably have to write a function that replaces and counts how many times it does so.

If anyone has any bright ideas or links to example code please let me know. I’ve started writing a clunky version that uses strpos() to find a the location of several words in a string, but doesn’t handle the replacement. There must be a better way!
