str_replace() ignores the count parameter?
<p>As given <a href="http://php.net/manual/en/function.str-replace.php" rel="nofollow">here</a> str_replace() count parameter should stop if certain replacements are done. Right?</p>

<p>Here is my code:</p>

<pre><code>define("PLACEHOLDER", "INSERT INTO `listings` VALUES (NULL, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s');".PHP_EOL);
$r = (4 - count($_POST['ad']));
print count($_POST['ad'])."\n";
print $r;
$pf_args = str_replace("'%s', ", "", PLACEHOLDER, $r);
print $pf_args;
</code></pre>

<p>Now I double-checked everything that <code>$r = 1</code> in one my test and to be doubly sure <code>count($_POST['ad'])</code> is 3. Still, str_replace completely ignores count parameter and replaces all occurances to give:</p>

<pre><code>INSERT INTO `listings` VALUES (NULL, '%s');
</code></pre>

<p>This is driving me insane. Having seen so much <a href="http://me.veekun.com/blog/2012/04/09/php-a-fractal-of-bad-design/" rel="nofollow">anti-php</a> talks, such eccentric behaviour(s) mkes me feel that they are bugs or another one of those weird magic it possesses.</p>
