Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/237.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何转换¶;(pilcrow)在从MySQL读取记录后\n在PHP中_Php - Fatal编程技术网

如何转换¶;(pilcrow)在从MySQL读取记录后\n在PHP中

如何转换¶;(pilcrow)在从MySQL读取记录后\n在PHP中,php,Php,在下面的代码中,当我在从mySQL数据库检索记录后回显“Details”列中的文本时,我希望它回显数据库记录中所有¨(pilcrow)的换行符() 我知道我可以使用nl2br()将所有\n替换为,但首先我需要将所有¨(pilcrow)替换为\n。我怎么做?这是我的密码: <?php $con = mysql_connect("localhost","peter","abc123"); if (!$con) { die('Could not connect: ' . mysql_er

在下面的代码中,当我在从mySQL数据库检索记录后回显“Details”列中的文本时,我希望它回显数据库记录中所有¨(pilcrow)的换行符(

我知道我可以使用
nl2br()
将所有\n替换为

,但首先我需要将所有¨(pilcrow)替换为
\n
。我怎么做?这是我的密码:

<?php
$con = mysql_connect("localhost","peter","abc123");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("my_db", $con);

$result = mysql_query("SELECT * FROM Persons");

while($row = mysql_fetch_array($result))
  {
  echo $row['Details'];
  }

mysql_close($con);
?>

只需使用类似以下内容:
$row['Details']=str_replace(“”,“\n”,$row['Details'])。这将把每个pilcrow都变成一个新行(当然,只要pilcrow没有编码)。

只需使用类似于
$row['Details']=str_replace(“”,“\n”,$row['Details'])。这将把每一个pilcrow都变成一个新行(当然,只要pilcrow没有编码)。

使用PHP函数:

str_replace('^','
',$row[“Details”]);
使用PHP函数:

str_replace('^','
',$row[“Details”]);
使用:
str_replace('''','
',$row[“Details']);
使用:
str_replace('''','
',$row[“Details'])
str_replace('¶', '<br>', $row["Details"]);