Hi, I would like to duplicate the pattern, the function will have 2 parameters, which is row and column. It will duplicate the pattern on how many rows and columns. My function for pattern is correct but how can I duplicate/replicate it. Thanks

<?php
$row_col_array = array();

function honey(){
  $l = "";
    for($i=2; $i<=4; $i++)
    {
     for($j=4; $j>=2; $j--)
     {
      if($i == $j)
       echo  "*";
      else
       echo "&nbsp;&nbsp;";
     }
     for($k=2; $k<=4; $k++)
     {
      if($i == $k)
      echo  "*";
      else
       echo "&nbsp;&nbsp;";
     }
     echo "<br>";
    }

    for($i=4; $i>=2; $i--)
    {
     for($j=4; $j>=2; $j--)
     {
      if($i == $j)
      echo "*";
      else
       echo "&nbsp;&nbsp;";
     }
     for($k=2; $k<=4; $k++)
     {
      if($i == $k)
      echo  "*";
      else
       echo "&nbsp;&nbsp;";
     }
     echo "<br>";
    }

}

honey();


?>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.