At first, I figured that the count parameter in the str_replace function is the limit on the number of substitutions (i.e., how many times you need to find and replace, thanks cap), but when I looked at the example in the official documentation, I had doubts. So what is this parameter for?

    2 answers 2


    If passed.

    Or in Russian. If transmitted, it will receive the number of substitutions performed.

      Here, count is passed in a variable. - This is a response to replacements made. If this value is 0, then nothing is found and there are no replacements. Although, if count could reflect the limit, then it would be called quanta. And if we could add the parameter rban - “allow | prohibit” repeated replacements to the function parameters, and in conclusion - the same count with its purpose ... - then the real str_replace () function would look more solid and without the above questions.