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
This commit is contained in:
Sean Harvey 2008-11-17 08:31:57 +00:00 committed by Sam Minnee
parent 3f154aaca1
commit 5df7e70cf8

View File

@ -104,7 +104,8 @@ class HTTP {
} }
static function findByTagAndAttribute($content, $attribs) { static function findByTagAndAttribute($content, $attribs) {
$regExps = array();
foreach($attribs as $tag => $attrib) { foreach($attribs as $tag => $attrib) {
if(!is_numeric($tag)) $tagPrefix = "$tag "; if(!is_numeric($tag)) $tagPrefix = "$tag ";
else $tagPrefix = ""; else $tagPrefix = "";
@ -114,8 +115,10 @@ class HTTP {
$regExps[] = "/(<{$tagPrefix}[^>]*$attrib *= *)([^\"' ]*)( )/ie"; $regExps[] = "/(<{$tagPrefix}[^>]*$attrib *= *)([^\"' ]*)( )/ie";
} }
foreach($regExps as $regExp) { if($regExps) {
$content = preg_replace($regExp, '$items[] = "$2"', $content); foreach($regExps as $regExp) {
$content = preg_replace($regExp, '$items[] = "$2"', $content);
}
} }
return isset($items) ? $items : null; return isset($items) ? $items : null;