Skip to content

Instantly share code, notes, and snippets.

@ken-master
Last active August 5, 2016 01:19
Show Gist options
  • Save ken-master/785d39c23a7fa525c06e to your computer and use it in GitHub Desktop.
Save ken-master/785d39c23a7fa525c06e to your computer and use it in GitHub Desktop.
Staircase Hash
<?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
#
##
###
####
#####
######
*/
@ahmadmuhbit
Copy link

This code does not run, there is another solution?
screen shot 2016-08-05 at 8 17 05 am

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment