在php中需要特定金字塔的代码

I have created like below:

$levels = 5;
$output = array();
for ($i = 1; $i <= $levels; $i = $i + 2) {
    $whitespace = ($levels - $i / 2 );
    $output[] = str_pad(' ', $whitespace, '-') . str_pad('', $i, '*');
}
echo implode("</br>", $output);
echo "
";
echo "</br>";
echo implode("</br>", array_reverse($output));
//echo "
";
echo "</br>";
---*
--***
-***** 
-*****
--***
---*

So, I need to hide or omit "-" from here.

   *
  ***
 ***** 
  ***
   *

Just echo it as:

<?php

echo "     *
    ***
   *****
  *******
   *****
    ***
     *";

You can use nl2br() to break the lines:

Inserts HTML line breaks before all newlines in a string

echo nl2br("
     *
    ***
   *****
  *******
   *****
    ***
     *");