php - For loop to print out squares of numbers -
i'm attempting create loop print out square of every number between 1-100.
<?php ($count = 1; $count < 100; $count++){ $squared = $count * $count; print("$count squared $squared"); } ?> what im getting this.
"1 squared 12 squared 43 squared 94 squared 165 squared 256" etc... i'm not sure i'm doing wrong.
edit: lifesavers , dumb, long live stack overflow.
you need add newline @ end of print \n should it
<?php ($count = 1; $count < 100; $count++){ $squared = $count * $count; print("$count squared $squared \n"); } ?> if output in html page, <br> perhaps way go!
Comments
Post a Comment