Using forloop to populate brackets
I want to learn to use for loop to populate brackets such as the
following:- $max starts at 8 and can be maximum of 512. I only know very
basics of forloop, not too well to form the below brackets.. can someone
help me on this and explain how they done it. Each goes into simple
pattern/sequence.
I appreciate it very much.
$max = 8;
if($max == 8)
[[0, 0], [0, 0]],
[[0, 0], [0, 0]],
[[0, 0]],
[[0, 0]]
if($max == 16)
[[0,0], [0,0], [0,0], [0,0]],
[[0,0], [0,0], [0,0], [0,0]],
[[0,0], [0,0]],
[[0,0], [0,0]],
[[0,0]],
[[0,0]]
if($max == 32)
[[0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0]],
[[0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0]],
[[0,0], [0,0], [0,0], [0,0]],
[[0,0], [0,0], [0,0], [0,0]],
[[0,0], [0,0]],
[[0,0], [0,0]],
[[0,0]],
[[0,0]]
etc until 512. Thanks
No comments:
Post a Comment