Page 1 of 1

need help with indentations

Posted: Mon Dec 27, 2010 3:15 am
by crazykeff
guys i am required to display my text document in textarea with proper columns but i can't seem to do it right. any ideas/tips?
____________________________________________________

this is an example how my text document content looks like with "|" as my indentation:
NAME|AGE|D.O.B
Samantha|15|12/05/1995
Billy|17|12/05/1993
____________________________________________________

this is an example how my text document content is required to display on the textarea of my webpage. The indentation sign has to be invisible and the content properly aligned like this:
NAME AGE D.O.B
Samantha 15 12/05/1995
Billy 17 12/05/1995
____________________________________________________

Can any genius help me plz?? :( :banghead:

Re: need help with indentations

Posted: Mon Dec 27, 2010 3:31 am
by cpetercarter
The purists will tell you that you should use CSS to position the various elements correctly on the page, but most practical people will use tables, like this:

Code: Select all

<table>
<tr>
    <th>Name</th>
    <th>Age</th>
    <th>Date of birth</th>
</tr>
<tr>
    <td>Samantha</td>
    <td>15</td>
    <td>12/05/1995</td>
</tr>
<tr>
    <td>Billy</td>
    <td>17</td>
    <td>12/05/1993</td>
</tr>
</table>

Re: need help with indentations

Posted: Mon Dec 27, 2010 5:41 am
by Darhazer
he asks about textarea
first, find the wider words in every of the groups
then use str_pad to pad any value to that length with empty spaces

Re: need help with indentations

Posted: Mon Dec 27, 2010 12:23 pm
by crazykeff
@cpetercarter: thx for your help but yea, i was referring to textarea :) thx though

@darzaher: hmm do u mean like using a loop to find the first "|" of every group to find the longest word then adding that value to str_pad??