Someone here is in denial , I see . <| sep |> Please bear in mind that I am still learning PHP so this may not be the most performant or ' best practice ' way of doing it but try this ? php $ arrayShape array array 0 , 0 , 0 , 1 , 0 , 0 , 0 , array 0 , 0 , 1 , 1 , 1 , 0 , 0 , array 0 , 1 , 1 , 1 , 1 , 1 , 0 , array 1 , 1 , 1 , 1 , 1 , 1 , 1 , array 0 , 1 , 1 , 1 , 1 , 1 , 0 , array 0 , 0 , 1 , 1 , 1 , 0 , 0 , array 0 , 0 , 0 , 1 , 0 , 0 , 0 $ intCounter count $ arrayShape echo table for $ i 0 $ i $ intCounter $ i echo tr foreach $ arrayShape as $ key $ value if $ value 1 echo tdtd else echo tdnbsptd echo tr echo table ? You can see a screenshot here basically we create the shape star in this case in an array . Each line is its own array using the value 0 or 1 . Later in the code we will convert the 0 to a space and the 1 to a star . We loop through the main array and for each line we create a new table row tr , within this row we loop through the value array . In this second loop we create a table column td and run our if statement . I hope this helps ! Edit spelling .