php - count occurences in preg_replace regex -
i know can find of occurrences preg_match_all
i.e.
<?php $text = 'here juice. juice...'; $counted = preg_match_all('/juice/',$text,$empt); echo $counted; ?>
but how can count occurrences preg_replace?
as per the manual, there optional 5th parameter $count
, set number of replacements performed:
preg_replace($pattern, $replacement, $subject, -1, $count)
the 4th parameter $limit
on number of replacements. -1
means no limit.
Comments
Post a Comment