<?php
$xyset
='false';
if(isset(
$_POST['col'])){
    if(isset(
$_POST['row'])){
        if(
is_numeric($_POST['col'])){
            if(
is_numeric($_POST['row'])){
                
$xyset=1;
            }
        }
    }
}
        
$col 64;
        
$row 64;
    if(
is_numeric($xyset)){
        
$col=$_POST['col'];
        
$row=$_POST['row'];
    }
?>
<form name="triangle" action="" method="POST">
<b>Columns:</b><input name="col" type="text" size="6" value="<?php echo $col?>">
<b>Rows:</b><input name="row" type="text" size="6" value="<?php echo $row?>">
<b>Symmetry:</b><input name="sym" type="checkbox"> (This makes it twice as wide)
<input type="submit" name="Generate">For best view, zoom out as far as you can. (Ctrl -)
<?php
    $thisuri 
$_SERVER['REQUEST_URI'];
    echo 
"<a href=\""."$thisuri"."s\">View Source</a></form>";
    if(
is_numeric($xyset)){
    echo 
'<pre>';
    
$var array_fill(0, ($col+1), 1);
    
$binvar $var;
    
$i 0;
    while(
$i $row){
    
$j 1;
        while(
$j $col){
            
$binvar[$j] = (($var[$j] +1) / 2);
            echo 
"$binvar[$j]";
            
$var[$j] = ($var[$j] * $var[$j+1]);
            
$j++;
        }
    
//     * This bit will mirror the triangle so you get more of a pyramid, symmetrical left-right, but a better option is to replace 1 with &nbsp; if it is to the right of any 0, and with a space if it's to the left of a zero and put the whole thing in a <center></center>

    
if(isset($_POST['sym'])){
        
$k $col;
    while(
$k 1){
        echo 
$binvar[$k--];
    }
    }
            
$var[$j] *= -1;
            echo 
'0<br>';
            
$i++;
    } 
//end check for $xyset
    
}
?>