dongrou839975 2011-06-26 12:16
浏览 56
已采纳

PHP:转换HTML以在标记中的alt / title属性中使用并保持格式

Essentially I have this

<p>hello</p>
<p>So I wanted just to say hi</p>
<p>I hope its going well</p>

Coming from a db.

If I just strip the tags then in the title I get this

title="helloSo I wanted just to say hiI hope its going well"

What I want (like SO does it).

title="Hello    
So I wanted just to say hi
I hope its going well"

I have tried using or and it just shows up in the title text.

title="Hello
So I wanted just to say hi
I hope its going well"

Is this possible because of using Markdown and the way SO is saving the text?

I'm using TinyMCE and I have looked into ways of formatting the text, I've even tried using the output buffer to try and arrange the text how I want it.

Edit: Lets make this really clear and simple. It's going into a TITLE element!

If I can't get this to work, I'll just do this via a popup with jQuery.

Any help / advise appreciated :)

  • 写回答

2条回答 默认 最新

  • dskzap8756 2011-06-26 12:21
    关注

    In PHP, The string ' ' is interpreted just like that and consist of four letters. The string " " is interpreted as escape sequences and contains two characters, a carriage return and a linefeed. Use double quotes if you want to insert a line break in a string.

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

报告相同问题?

悬赏问题

  • ¥15 vhdl+MODELSIM
  • ¥20 simulink中怎么使用solve函数?
  • ¥30 dspbuilder中使用signalcompiler时报错Error during compilation: Fitter failed,求解决办法
  • ¥15 gwas 分析-数据质控之过滤稀有突变中出现的问题
  • ¥15 没有注册类 (异常来自 HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))
  • ¥15 知识蒸馏实战博客问题
  • ¥15 用PLC设计纸袋糊底机送料系统
  • ¥15 simulink仿真中dtc控制永磁同步电机如何控制开关频率
  • ¥15 用C语言输入方程怎么
  • ¥15 网站显示不安全连接问题