php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #28408 preg_match can return an array, not only an int
Submitted: 2004-05-15 11:32 UTC Modified: 2004-05-21 16:04 UTC
From: Progman2002 at gmx dot de Assigned:
Status: Closed Package: Documentation problem
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: Progman2002 at gmx dot de
New email:
PHP Version: OS:

 

 [2004-05-15 11:32 UTC] Progman2002 at gmx dot de
Description:
------------
Its only a typo:

preg_match is defined as:

int preg_match ( string pattern, string subject [, array matches [, int flags [, int offset]]])

so, it will return an integer.. which is wrong:

| flags can be the following flag: 
|
| PREG_OFFSET_CAPTURE
|
| If this flag is passed, for every occurring match the 
| appendant string offset will also be returned. Note that 
| this changes the return value in an array where every
| element is an array consisting of the matched string at
| offset 0 and its string offset into subject at offset 1.
| This flag is available since PHP 4.3.0 .

So it can also return an Array.

|  preg_match() returns FALSE if an error occurred.

And it can return FALSE. So the "int" of the return-value must be changed to "mixed"


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-05-21 16:04 UTC] nlopess@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.


 [2020-02-07 06:12 UTC] phpdocbot@php.net
Automatic comment on behalf of nlopess
Revision: http://git.php.net/?p=doc/en.git;a=commit;h=51c605f72aba9c3a634ca2ced34ad91748c5a65e
Log: fix #28408: simple proto fix
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Wed Mar 11 01:00:02 2026 UTC