#31187 [NEW]: preg_match returning empty values

From: Date: Sun, 19 Dec 2004 20:28:44 +0000
Subject: #31187 [NEW]: preg_match returning empty values
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-70638@lists.php.net to get a copy of this message
From:             jackie at jdcdesigns dot com
Operating system: Apache 
PHP version:      4.3.10
PHP Bug Type:     Regexps related
Bug description:  preg_match returning empty values

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 bug report at http://bugs.php.net/?id=31187&edit=1
-- 
Try a CVS snapshot (php4):   http://bugs.php.net/fix.php?id=31187&r=trysnapshot4
Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=31187&r=trysnapshot50
Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=31187&r=trysnapshot51
Fixed in CVS:                http://bugs.php.net/fix.php?id=31187&r=fixedcvs
Fixed in release:            http://bugs.php.net/fix.php?id=31187&r=alreadyfixed
Need backtrace:              http://bugs.php.net/fix.php?id=31187&r=needtrace
Need Reproduce Script:       http://bugs.php.net/fix.php?id=31187&r=needscript
Try newer version:           http://bugs.php.net/fix.php?id=31187&r=oldversion
Not developer issue:         http://bugs.php.net/fix.php?id=31187&r=support
Expected behavior:           http://bugs.php.net/fix.php?id=31187&r=notwrong
Not enough info:             http://bugs.php.net/fix.php?id=31187&r=notenoughinfo
Submitted twice:             http://bugs.php.net/fix.php?id=31187&r=submittedtwice
register_globals:            http://bugs.php.net/fix.php?id=31187&r=globals
PHP 3 support discontinued:  http://bugs.php.net/fix.php?id=31187&r=php3
Daylight Savings:            http://bugs.php.net/fix.php?id=31187&r=dst
IIS Stability:               http://bugs.php.net/fix.php?id=31187&r=isapi
Install GNU Sed:             http://bugs.php.net/fix.php?id=31187&r=gnused
Floating point limitations:  http://bugs.php.net/fix.php?id=31187&r=float
No Zend Extensions:          http://bugs.php.net/fix.php?id=31187&r=nozend
MySQL Configuration Error:   http://bugs.php.net/fix.php?id=31187&r=mysqlcfg


Thread (3 messages)

« previous php.bugs (#70638) next »