您好我正在为移动设备制作一些格式,根据我的来源,它们最适合每行37个字符。
我们说我将一个字符串输入到一个正常的表格中。比方说每行80个字符,如:
INPUT:
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce eget risus porta, sodales ligula sed, ultricies sem. Praesent cursus, erat et consequat cursus, ante nisl placerat neque, ut maximus massa ipsum quis turpis. In mollis viverra nisl vitae pellentesque. Ut et tristique nisi. Duis nec lacinia enim. Vestibulum ultricies risus sed nibh imperdiet, nec venenatis libero suscipit. Morbi accumsan purus lectus, et commodo risus blandit at. Morbi luctus lacus dapibus, tempus est et, sollicitudin est. Phasellus sodales sodales eros. Proin dapibus pulvinar diam, ut pretium nisl pulvinar a. Donec nec lectus urna. Curabitur eu dolor pharetra, facilisis metus vitae, consectetur orci. Curabitur quis egestas mi, non tincidunt nisl.
我喜欢将/ n放在37个字符左右的例程,以便在移动设备的屏幕上轻松读取。
输出:
Lorem ipsum dolor sit amet,
consectetur adipiscing elit. Fusce
eget risus porta, sodales ligula sed,
ultricies sem. Praesent cursus, erat
et consequat cursus, ante nisl
placerat neque, ut maximus massa
ipsum quis turpis. In mollis viverra
nisl vitae pellentesque. Ut et
tristique nisi. Duis nec lacinia
enim. Vestibulum ultricies risus sed
nibh imperdiet, nec venenatis libero
suscipit. Morbi accumsan purus
lectus, et commodo risus blandit at.
Morbi luctus lacus dapibus, tempus
est et, sollicitudin est. Phasellus
sodales sodales eros. Proin dapibus
pulvinar diam, ut pretium nisl
pulvinar a. Donec nec lectus urna.
Curabitur eu dolor pharetra,
facilisis metus vitae, consectetur
orci. Curabitur quis egestas mi, non
tincidunt nisl.
每一行都有一个37列的回车符,保持单词一致。
这是我们正在编写的API的一部分,我们需要在输出字符串的变量中写入/。
输入字符串是表单字段,即
$input=$_POST['input'];
输出
<textarea name="str" id="textarea" cols="80" rows="20">
[print $output code goes here]
</textarea>
你们中有很多人问我为什么要这样做。原因如下:具体来说,我的指示是采用文本输入字符串并将其转换为18点Tahoma,每行末尾有37个cha {,<br>
。我可以做到这一点没问题,一旦我有一个带有新行或回车的字符串,所以我只是将这篇文章分解成一个简单的字符串问题而不是移动电子邮件哲学中的辩论!
当我将带有标点符号的文字像撇号(&#39;)输入到表单中然后将该输入反馈回<textarea>
时,它会在输出中添加一个额外的\。我试过str_replace但它似乎没有删除它。
输入:
Additional Strategies To This Case Study – Apply These To Propel Search Triggers’ Power To The Fullest!
Keep an 'arsenal' of keyword phrases, which you then 'sprinkle' into your titles, tags, and text from time to time. That's really the key. Finding those initial words you're pursuing is the most important factor. And then being consistent with your content on the site over spans of time, strategically incorporating the words you generated from Search Triggers (ST).
输出
Additional Strategies To This Case
Study – Apply These To Propel
Search Triggers’ Power To The
Fullest!
Keep an \'arsenal\' of keyword
phrases, which you then \'sprinkle\'
into your titles, tags, and text from
time to time. That\'s really the key.
Finding those initial words you\'re
pursuing is the most important
factor. And then being consistent
with your content on the site over
spans of time, strategically
incorporating the words you generated
from Search Triggers (ST).
如何删除文本区域输出字符串中撇号之前的\?
$str = str_replace( '', "\", $str);
无效,因为\被视为文字。谢谢!
答案 0 :(得分:1)
php函数wordwrap可以帮助你实现你想要的东西
答案 1 :(得分:0)
函数wordwrap完成了这项工作。我不知道存在这样的功能。谢谢!
<?php
$text = "The quick brown fox jumped over the lazy dog.";
$newtext = wordwrap($text, 20, "<br />\n");
echo $newtext;
?>