From: sgunderson@bigfoot.com <> Date: Wed, 4 Oct 2006 01:10:49 +0000 (+0200) Subject: Make PHP pass attribute3. X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=6e1365d9774efa69219c4d68d58256f0e6f875b6;p=xml-template Make PHP pass attribute3. --- diff --git a/php/xml-template.php b/php/xml-template.php index a0c6507..6fbf4bf 100644 --- a/php/xml-template.php +++ b/php/xml-template.php @@ -81,6 +81,10 @@ function XML_Template_process($node, $obj, $clean = 1) } foreach ($obj as $instance) { + if (!isset($instance)) { + continue; + } + $newnode = own_clone_node($frag, $frag->owner_document()); $node->append_child($newnode); XML_Template_process($newnode, $instance, $clean); @@ -131,8 +135,10 @@ function XML_Template_alternate($tag, $array, $elems) { $num = count($elems); - for ($i = 0; $i < count($array); $i++) { - $array[$i][$tag] = $elems[$i % $num]; + for ($i = 0, $j = 0; $i < count($array); $i++) { + if (isset($array[$i])) { + $array[$i][$tag] = $elems[$j++ % $num]; + } } return $array;