大家好。有必要使用 PHP 5.6 将长度超过 3000 个字符的文本分成不超过 500 个字符的片段。但与此同时,建议必须考虑在内。文本可能包含标签。例如,我们有一个 1398 个字符的文本:
Financial, commercial, legal, and intellectual factors changed the size of encyclopedias. During the <a href="/wiki/Renaissance" title="Renaissance">Renaissance</a>, middle classes had more time to read and encyclopedias helped them to learn more. Publishers wanted to increase their output so some countries like Germany started selling books missing alphabetical sections, to publish faster. Also, publishers could not afford all the resources by themselves, so multiple publishers would come together with their resources to create better encyclopedias. When publishing at the same rate became financially impossible, they turned to subscriptions and serial publications. This was risky for publishers because they had to find people that would pay all upfront or make payments. When this worked, capital would rise and there would be a steady income for encyclopedias. Later, rivalry grew, causing copyright to occur due to weak underdeveloped laws. Some publishers would copy another publisher's work to produce an encyclopedia faster and cheaper so consumers did not have to pay a lot and they would <a href="/wiki/encyclopedias" title="Renaissance">sell more</a>. Encyclopedias made it to where middle-class citizens could basically have a small library in their own house. Europeans were becoming more curious about their society around them causing them to revolt against their government.
您需要获取一个数组作为输出:
$result = [
// 393 символа
0 => "Financial, commercial, legal, and intellectual factors changed the size of encyclopedias. During the <a href=\"/wiki/Renaissance\" title=\"Renaissance\">Renaissance</a>, middle classes had more time to read and encyclopedias helped them to learn more. Publishers wanted to increase their output so some countries like Germany started selling books missing alphabetical sections, to publish faster.",
// 478 символов
1 => "Also, publishers could not afford all the resources by themselves, so multiple publishers would come together with their resources to create better encyclopedias. When publishing at the same rate became financially impossible, they turned to subscriptions and serial publications. This was risky for publishers because they had to find people that would pay all upfront or make payments. When this worked, capital would rise and there would be a steady income for encyclopedias.",
// 407 символов
2 => "Later, rivalry grew, causing copyright to occur due to weak underdeveloped laws. Some publishers would copy another publisher's work to produce an encyclopedia faster and cheaper so consumers did not have to pay a lot and they would <a href=\"/wiki/encyclopedias\" title=\"Renaissance\">sell more</a>. Encyclopedias made it to where middle-class citizens could basically have a small library in their own house.",
// Оставшаяся часть - 117 символов
3 => "Europeans were becoming more curious about their society around them causing them to revolt against their government."
];
请告诉我最好的方法来做到这一点。
打造属于自己的美...