#31187 [Opn->Bgs]: preg_match returning empty values
| From: | derick@php.net | Date: | Sun, 19 Dec 2004 20:39:45 +0000 |
| Subject: | #31187 [Opn->Bgs]: preg_match returning empty values | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-70640@lists.php.net to get a copy of this message | ||
ID: 31187
Updated by: derick@php.net
Reported By: jackie at jdcdesigns dot com
-Status: Open
+Status: Bogus
Bug Type: Regexps related
Operating System: Apache
PHP Version: 4.3.10
New Comment:
Do not file bugs when you have Zend extensions (zend_extension=)
loaded. Examples are Zend Optimizer, Zend Debugger, Turck MM Cache,
APC, Xdebug and ionCube loader. These extensions often modify engine
behavior which is not related to PHP itself.
.
Previous Comments:
------------------------------------------------------------------------
[2004-12-19 21:31:16] jackie at jdcdesigns dot com
please note that
"Expected result" and "Actual Result" are inversed
------------------------------------------------------------------------
[2004-12-19 21:28:43] jackie at jdcdesigns dot com
Description:
------------
When using preg_match or, preg_match all, it seems to be adding the
array key as the value, instead of the matched value for instance,
instead only the first match,
This problem does NOT exist on version 4.3.9
Reproduce code:
---------------
$string='<a href="http://www.example.com">Some Text</a>';
preg_match_all('/<\s*a\s*href="([^\"]+)"\s*>([^>]*)<\/a>/i',
$lines,
$main_array, PREG_SET_ORDER);
foreach($main_array as $main_code){
$url = $main_code[1];
$text = $main_code[2];
echo "$url $text\n";
}
print_r($main_array);
Expected result:
----------------
if $match[1] through $match[4] equals "abc"
$match[1] returns "0"
$match[2] returns "1"
$match[3] returns "2"
$match[4] returns "3"
Actual result:
--------------
if $match[1] through $match[4] equals "abc"
$match[1] should return "abc"
$match[2] should return "abc"
$match[3] should return "abc"
$match[4] should return "abc"
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=31187&edit=1