Přidat otázku mezi oblíbenéZasílat nové odpovědi e-mailemVyřešeno PHP - rozdělení dlouhého textu po 110 znacích do pole

Děkuji za reakci.

Nakonec jsem to v mezičase udělal trochu kratčeji a snad i přehledněji:


$description = "The World  Wide Web. When your average person on the street refers to
the Internet, they're usually thinking of the World Wide Web. The Web is basically a
series of documents shared with the world written in a coding language called Hyper Text
Markup Language or HTML. When you see a web page, like this one, you downloaded a document
from another computer which has been set up as a Web Server.";

//  Zde 50 znamena oddelit po padesáti znacích na nové řádky (\r\n)
$wrapped = wordwrap($description,50,"\r\n",TRUE);
// Vytvoří výsledné pole
$lines = explode("\r\n", $wrapped);

foreach ($lines as $line)
{
echo $line . '<br>';
}

Vstup:
The World Wide Web. When your average person on the street refers to the Internet, they're usually thinking of the World Wide Web. The Web is basically a series of documents shared with the world written in a coding language alled Hyper Text Markup Language or HTML. When you see a web page, like this one, you downloaded a document from another computer which has been set up as a Web Server.

Výstup:

The World Wide Web. When your average person on
the street refers to the Internet, they're usually
thinking of the World Wide Web. The Web is
basically a series of documents shared with the
world written in a coding language called Hyper
Text Markup Language or HTML. When you see a web
page, like this one, you downloaded a document
from another computer which has been set up as a
Web Server.

Reakce na odpověď

1 Zadajte svou přezdívku:
2 Napište svou odpověď:
3 Pokud chcete dostat ban, zadejte libovolný text:

Zpět do poradny