You want to have an inner loop for creating the spaces. Also, the innerloop has a different count for the spaces, the first one doesn't need to be indented. Here is a version for a console output:
for ($i=1; $i<=4; $i++)
{
for ($j=2; $j<=$i; $j++)
echo ' ';
echo '*';
echo "\r\n";
}
if you want to output it in HTML you might want to use this version:
for ($i=1; $i<=4; $i++)
{
for ($j=2; $j<=$i; $j++)
echo ' ';
echo '*';
echo "</br>";
}
Because in HTML consecutive spaces are ignored.