Re: Printing off the page....

Поиск
Список
Период
Сортировка
От Volkan YAZICI
Тема Re: Printing off the page....
Дата
Msg-id 7104a73705051304583d38f3ee@mail.gmail.com
обсуждение исходный текст
Ответ на Printing off the page....  (SG Edwards <s0460205@sms.ed.ac.uk>)
Ответы Re: Printing off the page....
Список pgsql-php
Hi,

On 5/13/05, SG Edwards <s0460205@sms.ed.ac.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.

В списке pgsql-php по дате отправления:

Предыдущее
От: David Blanco
Дата:
Сообщение: Re: Printing off the page....
Следующее
От: Volkan YAZICI
Дата:
Сообщение: Re: Printing off the page....