note 124690 added to function.preg-match

From: Date: Thu, 06 Feb 2020 16:42:52 +0000
Subject: note 124690 added to function.preg-match
Groups: php.notes 
Request: Send a blank email to php-notes+get-214011@lists.php.net to get a copy of this message
Combining flags PREG_OFFSET_CAPTURE | PREG_UNMATCHED_AS_NULL will NOT result in a value of NULL for any submatched subpattern. Instead still results in an array for each unmatched subpattern, in turn containing: array (size=2) 0 => null 1 => int -1 Consequently your code needs to expect NULL as the string value: $matches[ {subpattern+1} ][0] === null and/or a negative string offset: $matches[ {subpattern+1} ][1] < 0 to detect any unmatched subpattern! ---- Server IP: 45.112.84.4 Probable Submitter: 38.142.137.34 (proxied: 173.63.128.218) ---- Manual Page -- http://php.net/manual/en/function.preg-match.php Edit -- https://master.php.net/note/edit/124690 Del: integrated -- https://master.php.net/note/delete/124690/integrated Del: useless -- https://master.php.net/note/delete/124690/useless Del: bad code -- https://master.php.net/note/delete/124690/bad+code Del: spam -- https://master.php.net/note/delete/124690/spam Del: non-english -- https://master.php.net/note/delete/124690/non-english Del: in docs -- https://master.php.net/note/delete/124690/in+docs Del: other reasons-- https://master.php.net/note/delete/124690 Reject -- https://master.php.net/note/reject/124690 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#214011) next »