How can I convert ¶ (pilcrow) to \\n in PHP after reading a record from MySQL


In the following code when I echo the text in "Details" column after retrieving the record from mySQL database, I want it to echo line break (< br/ >) for all the ¶ (pilcrows) in the database record.

I know I can use nl2br() to replace all \n to <br/>, but first I need to replace all ¶ (pilcrows) to \n. How can I do it? Here is my code:

<?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); ?>


Simply use something like $row['Details'] = str_replace("¶", "\n", $row['Details']);. That will change every pilcrow into a newline (as long as the pilcrow isn't encoded, of course).


Use the PHP function <a href="http://php.net/manual/en/function.str-replace.php" rel="nofollow">str_replace</a>:

str_replace('¶', '<br>', $row["Details"]);


  • Add order customer note to YITH Woocommerce PDF Invoice
  • Unexpected T_ELSE in php code
  • How can display space in view blade laravel 5.3?
  • PHP displays \\r\\n characters when echoed in Textarea
  • Updating MS Access Database from Datagridview
  • vertically output the two dimensional array
  • Modifying the AJAX PHP database example
  • counting islands in R csv
  • how to check if a field is not unique
  • MySQl, join/merge 2 tables without shared column and ordering by a common column
  • Can't connect using mysql_connect to Database in ipage.com hosting?
  • How to get the second value in a dropdown box based on the selected one in the first dropdown box
  • Zend Framework 2, Module Redirect
  • Why does PHP appear to evaluate this condition incorrectly?
  • Contact form problem - I do receive messages, but no contents (blank page)
  • CORS with socket.io
  • mave 3.2 not able to access local nexus instance return 502 code
  • Tomcat memory Leak
  • SAXReader not re-ecape characters
  • Refering to the class itself from within a class mehod in Objective C
  • Checking free space on FTP server
  • Get data from AJAX - How to
  • Cannot resolve symbol 'MyApi'
  • ImageMagick, replace semi-transparent white with opaque white
  • FB SDK and cURL: Unknown SSL protocol error in connection to graph.facebook.com:443
  • Upload files with Ajax and Jquery
  • Do I've to free mysql result after storing it?
  • R: gsub and capture
  • AT Commands to Send SMS not working in Windows 8.1
  • A cron job substitute?
  • json Serialization in asp
  • How to get Windows thread pool to call class member function?
  • IndexOutOfRangeException on multidimensional array despite using GetLength check
  • costura.fody for a dll that references another dll
  • Observable and ngFor in Angular 2
  • How to Embed XSL into XML
  • UserPrincipal.Current returns apppool on IIS
  • Conditional In-Line CSS for IE and Others?
  • To Get the radio button value in ruby on rails
  • java string with new operator and a literal