Req #53238 [NEW]: Make third parameter of preg_match_all optional

From: Date: Wed, 03 Nov 2010 18:32:23 +0000
Subject: Req #53238 [NEW]: Make third parameter of preg_match_all optional
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-155744@lists.php.net to get a copy of this message
From:             
Operating system: any
PHP version:      5.3.3
Package:          PCRE related
Bug Type:         Feature/Change Request
Bug description:Make third parameter of preg_match_all optional

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)


-- 
Edit bug report at http://bugs.php.net/bug.php?id=53238&edit=1
-- 
Try a snapshot (PHP 5.2):            http://bugs.php.net/fix.php?id=53238&r=trysnapshot52
Try a snapshot (PHP 5.3):            http://bugs.php.net/fix.php?id=53238&r=trysnapshot53
Try a snapshot (trunk):              http://bugs.php.net/fix.php?id=53238&r=trysnapshottrunk
Fixed in SVN:                        http://bugs.php.net/fix.php?id=53238&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=53238&r=needdocs
Fixed in release:                    http://bugs.php.net/fix.php?id=53238&r=alreadyfixed
Need backtrace:                      http://bugs.php.net/fix.php?id=53238&r=needtrace
Need Reproduce Script:               http://bugs.php.net/fix.php?id=53238&r=needscript
Try newer version:                   http://bugs.php.net/fix.php?id=53238&r=oldversion
Not developer issue:                 http://bugs.php.net/fix.php?id=53238&r=support
Expected behavior:                   http://bugs.php.net/fix.php?id=53238&r=notwrong
Not enough info:                     http://bugs.php.net/fix.php?id=53238&r=notenoughinfo
Submitted twice:                     http://bugs.php.net/fix.php?id=53238&r=submittedtwice
register_globals:                    http://bugs.php.net/fix.php?id=53238&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=53238&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=53238&r=dst
IIS Stability:                       http://bugs.php.net/fix.php?id=53238&r=isapi
Install GNU Sed:                     http://bugs.php.net/fix.php?id=53238&r=gnused
Floating point limitations:          http://bugs.php.net/fix.php?id=53238&r=float
No Zend Extensions:                  http://bugs.php.net/fix.php?id=53238&r=nozend
MySQL Configuration Error:           http://bugs.php.net/fix.php?id=53238&r=mysqlcfg



Thread (6 messages)

« previous php.bugs (#155744) next »