From 5df7e70cf871b01ab49bef737437358e220d0b96 Mon Sep 17 00:00:00 2001 From: Sean Harvey Date: Mon, 17 Nov 2008 08:31:57 +0000 Subject: [PATCH] BUGFIX Fix PHP notice where variable with array didn't exist in HTTP->findByTagAndAttribute() git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.3@66043 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- core/HTTP.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/core/HTTP.php b/core/HTTP.php index 1ccaeb680..fb12e5521 100644 --- a/core/HTTP.php +++ b/core/HTTP.php @@ -104,7 +104,8 @@ class HTTP { } static function findByTagAndAttribute($content, $attribs) { - + $regExps = array(); + foreach($attribs as $tag => $attrib) { if(!is_numeric($tag)) $tagPrefix = "$tag "; else $tagPrefix = ""; @@ -114,8 +115,10 @@ class HTTP { $regExps[] = "/(<{$tagPrefix}[^>]*$attrib *= *)([^\"' ]*)( )/ie"; } - foreach($regExps as $regExp) { - $content = preg_replace($regExp, '$items[] = "$2"', $content); + if($regExps) { + foreach($regExps as $regExp) { + $content = preg_replace($regExp, '$items[] = "$2"', $content); + } } return isset($items) ? $items : null;