Lists: | pgsql-php |
---|
From: | SG Edwards <s0460205(at)sms(dot)ed(dot)ac(dot)uk> |
---|---|
To: | pgsql-php(at)postgresql(dot)org |
Subject: | Printing off the page.... |
Date: | 2005-05-13 09:55:12 |
Message-ID: | 1115978112.428479801cb7b@sms.ed.ac.uk |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-php |
Hi guys,
I have a postgres database connected to a website using PHP.
I have a table that stores gene sequences which are very long (approx. 800
characters).
If I try and print this, it prints as a single line which runs off the page. Is
there a way to print the sequence with a line break every 50 characters?
for example,
AAAAAAAAAAAACCCCCCCCCCC
TTTTTTTTTTTTTTTTGGGGGGG
AAAAAAAAATTT
Rather than:
AAAAAAAAAAACCCCCCCCCCCCTTTTTTTTTTTTTGGGGGGGGGGGAAAAAAAAAATTT
From: | David Blanco <dablanco(at)gmail(dot)com> |
---|---|
To: | pgsql-php(at)postgresql(dot)org |
Subject: | Re: Printing off the page.... |
Date: | 2005-05-13 11:49:03 |
Message-ID: | ef2a8951050513044942a5251a@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-php |
Hi!
2005/5/13, SG Edwards <s0460205(at)sms(dot)ed(dot)ac(dot)uk>:
>
> Hi guys,
>
> I have a postgres database connected to a website using PHP.
> I have a table that stores gene sequences which are very long (approx. 800
> characters).
>
> If I try and print this, it prints as a single line which runs off the page. Is
> there a way to print the sequence with a line break every 50 characters?
This seems to be a PHP question, not about PHP-Posgresql :-)
If I understood you right, you can do it with the PHP function "substr"
It's easy to iterate throug the string and to intercalate the line
breaks wherever you want
Bye
From: | Volkan YAZICI <volkan(dot)yazici(at)gmail(dot)com> |
---|---|
To: | SG Edwards <s0460205(at)sms(dot)ed(dot)ac(dot)uk> |
Cc: | pgsql-php(at)postgresql(dot)org |
Subject: | Re: Printing off the page.... |
Date: | 2005-05-13 11:58:50 |
Message-ID: | 7104a73705051304583d38f3ee@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-php |
Hi,
On 5/13/05, SG Edwards <s0460205(at)sms(dot)ed(dot)ac(dot)uk> wrote:
> I have a postgres database connected to a website using PHP.
> I have a table that stores gene sequences which are very long (approx. 800
> characters).
>
> If I try and print this, it prints as a single line which runs off the page. Is
> there a way to print the sequence with a line break every 50 characters?
>
> for example,
>
> AAAAAAAAAAAACCCCCCCCCCC
> TTTTTTTTTTTTTTTTGGGGGGG
> AAAAAAAAATTT
>
> Rather than:
> AAAAAAAAAAACCCCCCCCCCCCTTTTTTTTTTTTTGGGGGGGGGGGAAAAAAAAAATTT
You can write a simple wrap function for it. For example:
function wrapAndPrint($text, $maxLineLen = 50)
{
// We don't need to make a strlen() call everytime.
$lineLen = strlen($text);
for ( $i = 0; $i < $lineLen; $i++ )
print $text[$i].(( $i % $maxLineLen == 0 ) ? '\n' : '');
}
And then you can call wrapAndPrint() function everytime, when you need
to print fetched rows from the query result.
(Also it's possible to write a PL/WHATEVER function for it too.)
Regards.
From: | Volkan YAZICI <volkan(dot)yazici(at)gmail(dot)com> |
---|---|
To: | pgsql-php(at)postgresql(dot)org |
Subject: | Re: Printing off the page.... |
Date: | 2005-05-13 12:03:57 |
Message-ID: | 7104a73705051305037d299361@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-php |
Oops. I forgot some other built-in PHP functions.
I think it's more feasible to use chunk_split(). (You can take a look
at wordwrap() function too but I'd advice chunk_split(). Also
chunk_split() should work much faster than any other function we wrote
by using PHP.)
Regards.
From: | Christopher Kings-Lynne <chriskl(at)familyhealth(dot)com(dot)au> |
---|---|
To: | SG Edwards <s0460205(at)sms(dot)ed(dot)ac(dot)uk> |
Cc: | pgsql-php(at)postgresql(dot)org |
Subject: | Re: Printing off the page.... |
Date: | 2005-05-14 09:02:01 |
Message-ID: | 4285BE89.1080509@familyhealth.com.au |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-php |
Use the PHP wordwrap() function.
SG Edwards wrote:
> Hi guys,
>
> I have a postgres database connected to a website using PHP.
> I have a table that stores gene sequences which are very long (approx. 800
> characters).
>
> If I try and print this, it prints as a single line which runs off the page. Is
> there a way to print the sequence with a line break every 50 characters?
>
> for example,
>
> AAAAAAAAAAAACCCCCCCCCCC
> TTTTTTTTTTTTTTTTGGGGGGG
> AAAAAAAAATTT
>
>
> Rather than:
>
> AAAAAAAAAAACCCCCCCCCCCCTTTTTTTTTTTTTGGGGGGGGGGGAAAAAAAAAATTT
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo(at)postgresql(dot)org