loopsflowchart

Showing nested for loops in a flowchart


How could I show a nested loop in a flowchart?

I want to show a nested foreach loop in a flowchart that shows something like this

foreach($array as $item) {
    foreach($SecondArray as $key=>$value) {
        // Do stuff...
    }
}

Now correct me if I'm wrong, but there is no way to show a foreach loop in a flowchart, so I'd need to show a for loop in the diagram(?) So the algorithm should be shown as something more like:

for ($i = 0; $i < count($array); i++) {
    for ($j = 0; $j < count($arrayTwo); $j++) {
        // Do stuff...
    }
}

Now looking at the answers to this question (How to picture “for” loop in block representation of algorithm), a single for loop could be shown like this:

Flowchart for single loop

But I cannot think of any way in which I could show a nested loop (to show the code I wrote above).

Any suggestions?


Solution

  • This is what you are looking for.

    enter image description here

    You can see other interesting flowchart for nested loops here.