ID: 14220 Updated by: mfischer Reported By: [EMAIL PROTECTED] Old Status: Closed Status: Bogus Bug Type: Output Control Operating System: Win2K PHP Version: 4.0.6 New Comment:
We rather call it Bogus than Goofy ;) Previous Comments: ------------------------------------------------------------------------ [2001-11-25 23:34:36] [EMAIL PROTECTED] Code was goofy .... only been looking at for a few days wondering what was going on ------------------------------------------------------------------------ [2001-11-25 23:18:48] [EMAIL PROTECTED] I'm running the following function in conjunction with the DOM XML stuff to create a SAX parser. Trouble is that the following code doesn't seem to stop iterating over the $startTags array when it hits the break command. function startElement ($parser, $name, $attrs) { global $startTags, $xmlPath, $htmlContent, $monthWords; $xmlPath .= "/$name"; foreach ($startTags as $tag => $value) { if (substr($xmlPath, strlen($xmlPath) - strlen($tag), strlen($tag)) == $tag) { $htmlContent .= $startTags[$tag]; if ($name == "url") { if (isset ($attrs["target"])) { $htmlContent .= " target=\"$attrs[target]\""; } $htmlContent .= " href=\"$attrs[page]\">"; break; // Stop iterating through tags } else if ($tag == "events/date") { $htmlContent .= "<div class=\"hdr2\">" . $monthWords[$attrs["month"]] . ", $attrs[year]</div></div>\n<div class=\"content\">"; } } } } An exmaple array for $startTags is as follows: $startTags = array ( "content/section" => "<div class=\"content\">", "text" => "<div class=\"txt2\">", "list" => "<ul class=\"listtext\">", "list/item" => "<li>", "item" => "junk" ); If you were trying to match up the item tag, then the loop would actually print out the value of list/item and item, instead of breaking after it found list/item. This also assumes that the xml for this match is like this <list> <item>point 1</item> <item>point 2</item> </list> ------------------------------------------------------------------------ Edit this bug report at http://bugs.php.net/?id=14220&edit=1 -- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]