]> git.sesse.net Git - xml-template/commitdiff
Make PHP pass attribute3.
authorsgunderson@bigfoot.com <>
Wed, 4 Oct 2006 01:10:49 +0000 (03:10 +0200)
committersgunderson@bigfoot.com <>
Wed, 4 Oct 2006 01:10:49 +0000 (03:10 +0200)
php/xml-template.php

index a0c65078a831dfe21f12c39452f582f280cd3429..6fbf4bf8962c246740c619045985d176be34dae4 100644 (file)
@@ -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;