need help with indentations

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
crazykeff
Forum Newbie
Posts: 8
Joined: Wed Oct 27, 2010 1:29 am

need help with indentations

Post 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:
cpetercarter
Forum Contributor
Posts: 474
Joined: Sat Jul 25, 2009 2:00 am

Re: need help with indentations

Post 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>
User avatar
Darhazer
DevNet Resident
Posts: 1011
Joined: Thu May 14, 2009 3:00 pm
Location: HellCity, Bulgaria

Re: need help with indentations

Post 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
crazykeff
Forum Newbie
Posts: 8
Joined: Wed Oct 27, 2010 1:29 am

Re: need help with indentations

Post 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??
Post Reply