dqx13503925528 2013-09-05 14:47
浏览 59
已采纳

PHP输出中限制的行或字符

I got a weird Problem here, need your help. PHP Language.

Suppose I have a Output like this:

A
B
C
D
E

Now Instead of 5 Lines, I want out in 2 Lines and 3rd line will be "more" which will take him to another page for details(I know how to place anchor tag :S)

And if The ouput is like

This is a big paragraph of 5 lines or maybe more, but what I want to display is only first 100(or some first n Characters). Repeated This is a big paragraph of 5 lines or maybe more, but what I want to display is only first 100(or some first n Characters)This is a big paragraph of 5 lines or maybe more, but what I want to display is only first 100(or some first n Characters)This is a big paragraph of 5 lines or maybe more, but what I want to display is only first 100(or some first n Characters)This is a big paragraph of 5 lines or maybe more, but what I want to display is only first 100(or some first n Characters).

Instead of this I want to display only first 100 characters and then a more button which will take to a detailed page.

The Second Problem can be solved with php function substr, but what about the first one ? I need both cases to work at same place, like if input has some list(hell of newline characters) at starting then only top 2 lines will be printed And if it is a paragraph then only first 100(or some n) characters(or even words) will be printed.
Any Guesses ?

  • 写回答

2条回答 默认 最新

  • duanqinbi9029 2013-09-05 14:53
    关注

    You can use substr and then ajax to load the whole string. But you can also use CSS to display first X lines - set height and overflow: hidden. Then again javascript to unset the height and overflow.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 关于用pyqt6的项目开发该怎么把前段后端和业务层分离
  • ¥30 线性代数的问题,我真的忘了线代的知识了
  • ¥15 有谁能够把华为matebook e 高通骁龙850刷成安卓系统,或者安装安卓系统
  • ¥188 需要修改一个工具,懂得汇编的人来。
  • ¥15 livecharts wpf piechart 属性
  • ¥20 数学建模,尽量用matlab回答,论文格式
  • ¥15 昨天挂载了一下u盘,然后拔了
  • ¥30 win from 窗口最大最小化,控件放大缩小,闪烁问题
  • ¥20 易康econgnition精度验证
  • ¥15 msix packaging tool打包问题