Last active
August 5, 2016 01:19
-
-
Save ken-master/785d39c23a7fa525c06e to your computer and use it in GitHub Desktop.
Staircase Hash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$n = 50; | |
$hash = str_repeat("#",$n); | |
for($x = $n;$x>=0;$x--){ | |
$test = preg_replace("/\#/"," ",$hash,$x); | |
if( !ctype_space($test) ){ | |
echo $test."\n"; | |
} | |
} | |
/* Sample OUTPUT | |
# | |
## | |
### | |
#### | |
##### | |
###### | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This code does not run, there is another solution?
![screen shot 2016-08-05 at 8 17 05 am](https://cloud.githubusercontent.com/assets/20849439/17423494/35e9b2b0-5ae5-11e6-90af-cb92e6efe611.png)