<?php$rows=5; // Number of rowsfor ($i=$rows; $i>=1; $i--) {for($j=1; $j <=$i; $j++){echo"* ";} echo "\n"; // new line}?>
🔹 Output (for $rows = 5):
***************
✅ 2. Matrix Approach.
<?phpfunctionprintInvertedLeftTriangleMatrix($n){// Loop through rowsfor ($i=1;$i<=$n;$i++) {// Loop through columns (matrix style)for ($j=1;$j<=$n;$j++) {if ($j<= ($n-$i+1)) {echo"*";}else{echo"";// fill remaining with spaces}}echoPHP_EOL;}}// Example usage$n=5;printInvertedLeftTriangleMatrix($n);?>