Menu

Outer loop key() access within Inner loop

2013-04-10
2013-04-10
  • Somwrita Debnath

    I want to implement the following logic in figdice:

    <?php
    for ($i=0; $i<count($arr1); $i++)
    {
      for ($j=0; $j<count($arr2); $j++)
      {
        if($i==$j)       //checking index of two array
          //do something;
    
      }
    }
    

    I want to compare the key of the inner loop with the key of the outer loop. But when I used the function key() its only given the key of the inner array. I am unable to fetch the key of outer array.

     

    Last edit: Gabriel Zerbib 2013-04-10
    • Somwrita Debnath

      SOLUTION:

      We could capture the key() of the outer Walk, into a local variable.
      Example:

      <div fig:walk="outer">
        <fig:mount target="outerKey" value="key()">
          <span fig:walk="inner">
            <div fig:cond="/outerKey == key()"> ... </div>
          </span>
      </div>
      
       

      Last edit: Gabriel Zerbib 2013-04-10

Anonymous
Anonymous

Add attachments
Cancel