0

つまり、最終的には雑誌スタイルでフォーマットされたデータベースからデータを表示するという考えです。文字列を列に分割したいのですが、特定のブラウザーでは互換性がないため、css3 の列機能を使用しません。

私は文字列を新しい div でかなり停止して開始し、中断したところから始めました。明らかに後でページネーションを行うことになりますが、今のところ、単語が分割されたときにいくつかの単語が 2 つに分割されています。別の部門。ただし、ここの別のページのいくつかの指示に従ったため、単語の分割が停止するはずだったので、何が起こっているのかわかりません。あなたたちが助けてくれるかどうか疑問に思っています。ここにページがあります:

これは PHP ファイル "./data/lost.php" で、文字列が一時的に取り出されます (ここでは、本文の文字列を短くしていますが、おわかりのとおりです)。

<?php
$title = "This is where the title will go...";
$username = "[Full Name]";
$date = "[Creation Date]";
$body = 'The first season begins with a plane crash that leaves the surviving passengers of Oceanic Airlines Flight 815 on what seems to be a deserted tropical island. Their survival is threatened by a number of mysterious entities, including polar bears, an unseen creature that roams the jungle (the "Smoke Monster"), and the island\'s malevolent inhabitants known as "the Others"...';
$quote = '"This is a space reserved for a quote..."';

?>

ページのphpは次のとおりです。

    <?php

require_once('./data/lost.php');

function text($text,$limit,$length)
{
$newbody = substr($text, $length, strpos(wordwrap($text, $limit), "\n"));

global $newlength;
$newlength = ($length + strlen($newbody));

return $newbody;
};

echo "

<div id='wrapper'>
            <div id='articlecont'>
                    <div id='title'>". $title ."</div>
                    <div class='col12'>
                        <div id='artimage'>An Image will go here...</div>
                        <div class='col1'><span style='font-size:0.8em;'>Author: ". $username ." on: ". $date ."</span><br />
<br />". text($body,495, 0) ."</div>
                            <div class='col2'>". text($body,520, $newlength) ."</div>
                        </div>
                        <div class='col22'>
                            <div class='col31'>". text($body,390, $newlength) ."</div>
                        <div class='quote'>". $quote ."</div>
                        <div class='col32'>". text($body,260, $newlength) ."</div>
                    </div>
                    <div class='col4'>". text($body,3000, $newlength) ."</div>
            </div>
        </div>


    </body>
</html>";

?>

ご協力いただきありがとうございます。返信を確認し続けます。

4

1 に答える 1

0

substr()引数を確認してください。2 番目のパラメータは start で、3 番目は長さです

<a href="http://php.net/manual/en/function.substr.php" rel="nofollow">substr()

于 2013-06-04T00:33:01.867 に答える