English 中文(简体)
• 如何将案文分解到设在营地的下行?
原标题:How to break a text into the next line in php?
  • 时间:2011-07-26 17:52:07
  •  标签:
  • php
  • html

i 这个项目是博客,由我从服务器上提取员额。 问题是,当该员额被重复使用时,案文一行不变,我如何在一段长后进入下行?

Here is the code where the text is being posted

$postpost = $result["post_user"];
echo " <b>name</b> = " .$result["username"] ."<br>";
echo " <b>post</b> = " .$result["post"] . "<br>";
echo " <b>date</b> = ".$date["date"]. " 
<br><br>----------------------<br><br>";

and here is the output problem enter image description here

问题回答

使用wordwrap(:

// the 80 is the number of characters after which to break:
echo " <b>post</b> = " . wordwrap($result["post"], 80,  <br> ) .  <br> ;

http://php.net/nl2br"rel=“noretinger”>nl2br(

$postpost = $result["post_user"];
echo " <b>name</b> = " .$result["username"] ."<br>";
echo " <b>post</b> = " .chunk_split($result["post"],100,"<br/>") . "<br>";
echo " <b>date</b> = ".$date["date"]. " 
<br><br>----------------------<br><br>";

这将在100个特性之后打破。 你可以把100人改为你们的需要。

但是,言行是更好的解决办法:

您可以在工作场所使用字句功能

<?php
  $text = "The quick brown fox jumped over the lazy dog.";
  $newtext = wordwrap($text, 20, "<br />
");
  echo $newtext;
?>
echo implode( <br/> ,str_split($string,100));

首先,如果你希望文本有最长的宽度,则在包装上附上整个内容:<代码><div>要素,并使用特别安全局将其作到最大宽度。 该要素内的任何案文,一经总结。

这里,需要:

#mydiv {width:200px;}

唯一的案文在案文中没有任何空间,仍然会超出页面。

为此,你可以使用另一个特别安全局的财产,word-wrap

#mydiv {word-wrap:break-word;}

最佳做法是使你的特别安全法与你的超文本分开,但如果你不使用风格表,你可以将特别安全法直接添加到<代码><div>要素中等:

<div style= width:200px; word-wrap:break-word; >
    ..... (your content goes here) .....
</div>

当然,使用<密码wrap()功能(或str_split(<>>>)进行长期扼杀,没有空间,但是,如果在网页上显示,时间长短不一,则你最终可使用不同的字句,因为字体具有不同的特性。 因此,我要说,特别安全局的解决办法是较好的,因为“总结”一词将放在网页上。

希望会有所帮助。

应:

$newtext = wordwrap($text, 20, "<br />
");

实例见http://php.net/wordwrap”rel=“nofollow”>。

www.un.org/Depts/DGACM/index_spanish.htm Edit:我最初认为这是一个中心问题。 我看到,你希望打破与“基地”组织非常庞大的地带。 如第条所建议的,你可以为此使用“一”二字。

What I initially thought in CSS: put each blog entry into a div, and assign word-wrap: break-word; for the div and also specify width of the div.

我关于jsfiddle.com的想法:Link





相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签