|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2010-11-03 19:32 UTC] giovanni at giacobbi dot net
Description:
------------
I had to count the time a regular expression is in a string, and the correct way to do this is with the return value of preg_match_all() because preg_match() will always return either 0 or 1.
The problem is that preg_match_all() enforces the third parameter. My request is to align the prototype of preg_match_all() to the one of preg_match(), i.e. making the third parameter optional.
Test script:
---------------
$cnt = preg_match_all('/<br\s*\/?>/i', "this<br/>my<br>text");
var_dump($cnt);
Expected result:
----------------
int(2)
Actual result:
--------------
Warning: preg_match_all() expects at least 3 parameters, 2 given in - on line 2
bool(false)
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 22 21:00:01 2025 UTC |
Hi aharvey, thank you for the extremely quick reaction. Two things: I think you misplaced the [, it's supposed to go in front of the comma: -/* {{{ proto int preg_match_all(string pattern, string subject, array &subpatterns [, int flags [, int offset]]) +/* {{{ proto int preg_match_all(string pattern, string subject, [array &subpatterns [, int flags [, int offset]]]) second thing is.. any chance to have this backported for 5.3.4? There is no BC break since it's a parameter that becomes optional. I understand if you want to keep all API changes for minor version, it's what I would do as well..only problem with PHP is that it has a too slow release cycle. Thank you anyway, I really appreciate your support.