| 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: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| 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 | Date | Subject | |
|---|---|---|---|
| Next Message | Volkan YAZICI | 2005-05-13 12:03:57 | Re: Printing off the page.... |
| Previous Message | David Blanco | 2005-05-13 11:49:03 | Re: Printing off the page.... |