Recurring circum (phalcon)



  •  <?php
    
        $n=0;
        function data($parent_id, $robots2, $n, $type_id) {
            $n++;
            foreach ($robots2 as $robot):
                if ($robot->parent_id==$parent_id): ?>
                    <p style = "margin-left:<?php echo 1+$n;?>%"><?php echo $robot->name;?></p>
                    <?php
                        data($robot->id, $robots2, $n, $type_id);
                    ?> 
                <?php endif;
            endforeach;
            $n--;
        }
    ?>
    

    There's no way the first element is fuller.

    I mean.
    Element 1
    Element 1.1.
    Element 1.1.1
    And Element 2 doesn't come out. Tell me, people are good to do. ♪ ♪



  • $n=0;
    
    function data($parent_id, $robots2, $n, $type_id) {
        $n++; // здесь 1
        foreach ($robots2 as $robot):
            if ($robot->parent_id==$parent_id):?>
                <p style = "margin-left:<?php echo 1+$n;?>%"><?php echo $robot->name;?></p>
                <?php
                    data($robot->id, $robots2, $n, $type_id);
                ?> 
            <?php endif;
        endforeach;
        $n--; // здесь опять 0
    }
    



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2