如何将 MySQL 内容(文本+html 内容)分成几列? [英] How to break MySQL content(text+html content) into columns?

查看:26
本文介绍了如何将 MySQL 内容(文本+html 内容)分成几列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,我想提一下,我理解每个人在不提供至少一些试验或错误的情况下提问的感觉,但这纯粹是需要了解知识,话虽如此,我还是会去提前询问.

As a first, I'd like to mention that I understand how everyone feels towards asking questions without providing at least some trial or errors, yet this is purely a need to know knowledge, with that being said, I'll go ahead and ask.

我一直无法弄清楚如何将内容分成 3 个部分,比如保存在 MySQL 表中的 600-1000 个文本单词,以便在这些部分之间可以包含特定的 java 或使其更容易理解图片.

I haven't been able to figure out how to break content let's say 600-1000 text words saved in a MySQL table into 3 sections, so that in between these sections it could include specific java or to make it easier to understand images.

假设我们从 MySQL 中检索 800 个单词的文本,我们的目标就是这样做.

Let's say we retrieve 800 word text from MySQL, the goal would be to do this.

Content    
========= Section Break [image] ==========
Content
========= Section Break [image] ==========

到目前为止,我已经知道了(继续尝试通过不包含任何内容来解决问题),但它破坏了句子中间的文本,我想至少在最后打破.(点)在那条线上.

I've got this so far, (went ahead and tried to save problems by not including anything), but it is breaking the text in the middle of the sentence, where I'd like to break at least at the last .(dot) on that line.

$text = stripslashes($article_content); 

$first = strpos($text," ",strlen($text) / 2);
$col1 = substr($text, 0, $first);
$col2 = substr($text, $first);

echo $col1;
echo "this is the line break";
echo $col2; 

而这个它不打印 <br/> ($separator).

and this one it does not print the <br/> ($separator).

$separator = "<br/>";

$text = stripslashes($article_content); 
$first = ceil(strlen($text) / 3);

$string = substr($text, 0, $first);
$string = $separator;
$string = substr($text,$first,$first);
$string = $separator;
$string = substr($text,($first*2), $first);

echo $string;

  1. 第一个我无法让它在该行的最后一个 .(点)处中断.
  2. 它不打印分隔符,也不知道为什么,但是文本打印效果很好.

推荐答案

在变量 $string 的第一次实例化之后,在等号前使用一个点来添加到您的第二个示例中.>

Use a dot before the equalssign after the first instantiation of the variable $string to add to it in your second example.

$separator = "<br/>";

$text = stripslashes($article_content); 
$first = ceil(strlen($text) / 3);

$string = substr($text, 0, $first);
$string .= $separator;
$string .= substr($text,$first,$first);
$string .= $separator;
$string .= substr($text,($first*2), $first);

echo $string;

这篇关于如何将 MySQL 内容(文本+html 内容)分成几列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆