Q:

Print numbers in diamond shape PHP

$arr = array(1,2,4,7,12,17,21,24,26,27);
for($i=1; $i<count($arr); $i++) {
    for($j=$arr[$i-1]; $j<$arr[$i]; $j++) {
        echo $j;
    }
    echo "<br>";
}

I am trying to use for loops to make a shape that looks like the diamond shape . at this time it's look like half diamond shape.
i want to help in this .

A:

This is the best I could come up with:
echo '<pre style="text-align:center;">';
$arr = array(1,2,4,7,12,17,21,24,26,27);
for($i=1; $i<count($arr); $i++) {
    for($j=$arr[$i-1]; $j<$arr[$i]; $j++) {
        echo $j;
    }
    echo "<br>";
}

So what you want is (without the shape):
      1
     2  4
 7  12  17  21 
    24  26
      27

I'm having trouble getting where the lines break, since the numbers in the array don't come out to a "symmetrical" number.
Or do you want this:
       1 
      2  4
     7    12
    17     21 
     24   26
        27

