我需要echo一段html代码如果html代码里面有换行的话 无法echo输出请问怎么将 一段html代码 格式化成一行! 从而可以
$msg="xxxxxHTMLCODExxxxx";
echo $msg;
$msg="xxxxxHTMLCODExxxxx";
echo $msg;
解决方案 »
- 准备学习PHP,哪位高手给我点意见
- 关于DEDECMS后台的发送邮件函数
- PHP Session的一个疑问
- 如何在xp下,安装imail8.0,一安装就说安装程序必须被关闭,无法继续?怎么办?
- 请问怎样得到以下字符,谢谢
- 关于信息搜索的问题
- Window 下的Apache速度是不是很慢?
- 学习php时,能借助apache访问*.php,但访问不了文件夹
- 前辈们帮我看一下下面的代码错在哪里
- 'select * from article where cid='.$cid.'order by aid desc limit 20'有问题吗?
- 向nginx发起两次请求,第二次无效,请求高人帮助
- HTTP 错误 500.0 - Internal Server Error
你只需
echo preg_replace("/[\r\n]+/", '\\n', $msg);
即可
nl2br可以把换行字元转成 <br>
还不如版主的正则呢
<table id="table30" style="BORDER-COLLAPSE: collapse" cellpadding="0" width="100%" border="0" align="center">
<tbody>
<tr>
<td><table width="700" align="center" border="0" cellspacing="0" cellpadding="0" bordercolor="#ffffff">
<tbody><tr>
<td height="260" bordercolor="#FFFFFF" bgcolor="#FFFFFF"> <table width="0" border="0" align="center" cellpadding="0" cellspacing="0">
<tbody><tr>
<td><img src="imagess/piaodian/hyzx_title.gif" width="651" height="89"></td>
</tr>
</tbody></table>
<table width="659" height="243" border="0" align="center" cellpadding="0" cellspacing="0">
<tbody><tr>
<td bgcolor="#F7F7F7"><div align="center"><table width="606" border="0" align="center" bgcolor="#FFFFFF" class="unnamed3">
<tbody><tr>
<td width="633"><table width="600" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" class="table">
<tbody><tr>
<td width="633" colspan="5"><img src="imagess/huiyuan_login.gif" width="140" height="46"></td>
</tr>
<tr>
<td height="3" colspan="5" bgcolor="#FF9900"></td>
</tr>
</tbody></table></td>
</tr>
<tr>
<td valign="top"><table width="592" border="0" align="center" cellpadding="5" cellspacing="0">
<form name="fkinfo" method="post" action="checkuserlogin.asp"></form>
<tbody><tr>
<td width="18%" align="right">用户名:</td>
<td width="24%">
<input name="username" class="wenbenkuang" type="text" id="username2" maxlength="18" size="18"></td>
<td width="22%" rowspan="2"><input name="imageField" type="image" onfocus="this.blur()" value="登 陆" src="imagess/piaodian/btn_login.gif"></td>
<td width="36%" rowspan="2"><a href="reg.asp"><img src="imagess/btn_register.gif" width="162" height="44" border="0"></a></td>
</tr>
<tr>
<td width="18%" align="right">密 码:</td>
<td width="24%">
<input name="userpassword" class="wenbenkuang" type="password" id="userpassword2" maxlength="18" size="18">
<input class="wenbenkuang" type="hidden" name="linkaddress" value="user.asp">
</td>
</tr>
<tr>
<td width="18%" align="right">验证码:</td>
<td width="24%">
<input class="wenbenkuang" name="verifycode" type="text" value="" maxlength="4" size="10">
<img src="GetCode.asp"> </td>
我的$msg里面是这个内容哦
我是想吧比如一段代码<table width="659" height="243" border="0" align="center" cellpadding="0" cellspacing="0">
<tbody><tr>
<td bgcolor="#F7F7F7"><div align="center"><table width="606" border="0" align="center" bgcolor="#FFFFFF" class="unnamed3">
<tbody><tr>这样的代码。格式换成<table width="659" height="243" border="0" align="center" cellpadding="0" cellspacing="0"><tbody><tr><td bgcolor="#F7F7F7"><div align="center"><table width="606" border="0" align="center" bgcolor="#FFFFFF" class="unnamed3"><tbody><tr>这样的