Jump to content

How To Arrange The Number To Column By Column


traisylee
 Share

Recommended Posts

Hi, my problem now is how can i arrange the number be smart?Below is my code number::)

<html><body><?php$input=3.13;$N=20;for($j=0;$j<=$N;$j++){   $input=$input*3;   echo "|  " .str_pad($input,15," "). "  |  " .str_pad($input,15," "). "  |  " .str_pad($input,15," "). "  |</br>";}?></body></html>

How can i build my coding be the ouput like below?

|  9.39		  |  9.39			  |  9.39			  ||  28.17		 |  28.17			 |  28.17			 ||  84.51		 |  84.51			 |  84.51			 ||  253.53		|  253.53			|  253.53			||  760.59		|  760.59			|  760.59			||  2281.77	   |  2281.77		   |  2281.77		   ||  6845.31	   |  6845.31		   |  6845.31		   ||  20535.93	  |  20535.93		  |  20535.93		  ||  61607.79	  |  61607.79		  |  61607.79		  ||  184823.37	 |  184823.37		 |  184823.37		 |

I hope got people can help me. Thanks! :)

Edited by traisylee
Link to comment
Share on other sites

maybe javascript might be more suitable for this? It might be easier using that and using it to create a loop to print out a table with those numbers in it. Or maybe just cho out HTML table data to organize those numbers, using a loop to make all three columns.

Link to comment
Share on other sites

I was thinking it only printed out one column?
My problem is the output can not be arrange like about output.Why u say only can printed out one column?Above coding can printed out 3 column but it can not be arrange better.If i use above coding it will printer out as below:
Link to comment
Share on other sites

If you ask me the below code will output the same list in a table format.

<html><body><?php$input=3.13;$N=20;echo "<table>";for($j=0;$j<=$N;$j++){   $input=$input*3;   echo "<tr><td>|" .str_pad($input,15," "). "|</td><td>|" .str_pad($input,15," "). "|</td><td>|" .str_pad($input,15," "). "|</td></tr>";}echo "</table>";?></body></html>

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...