I am trying to run a script through command prompt in PHP and trying to show the result in tabular form. But due to different character length of words I am not able to show the result properly align.
I want result like this
Book ISBN Department
Operating System 101 CS
C 102 CS
java 103 CS
Can anyone please help me to get this output like this in php on console.
Thanks in advance
If you don’t want (or not allowed for some reason) to use libraries, you can use standard php
printf/sprintffunctions.The problem with them that if you have values with variable and non-limited width, then you will have to decide if long values will be truncated or break table’s layout.
First case:
The output is
Second case:
And here we get
If neither of that satisfies your needs and you really need a table with flowing width columns, than you have to calculate maximum width of values in each column. But that is how
PEAR::Console_Tableexactly works.