note 104890 added to function.str-replace
| From: | mbullard at accuvista dot co dot uk | Date: | Thu, 14 Jul 2011 09:42:18 +0000 |
| Subject: | note 104890 added to function.str-replace | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-181491@lists.php.net to get a copy of this message | ||
Insert space after comma.
If you have a form that stores results in a database field as comma separated values, when you
display this data you can use the following to insert a space after each comma:
<?php
$find[] = ',';
$replace[] = ', ';
$text = str_replace($find, $replace, $row_rsRecordset['Field']);
print_r($text);
?>
Notes:
1) To get round the Replacement Order Gotcha, the comma is also replaced with its code equivalent:
,
2) You can adapt the $replace section to suit your needs: swap out the code with
<br/> or replace comma and space with · etc.
----
Server IP: 92.48.74.199
Probable Submitter: 86.161.138.1
----
Manual Page -- http://www.php.net/manual/en/function.str-replace.php
Edit -- https://master.php.net/note/edit/104890
Del: integrated -- https://master.php.net/note/delete/104890/integrated
Del: useless -- https://master.php.net/note/delete/104890/useless
Del: bad code -- https://master.php.net/note/delete/104890/bad+code
Del: spam -- https://master.php.net/note/delete/104890/spam
Del: non-english -- https://master.php.net/note/delete/104890/non-english
Del: in docs -- https://master.php.net/note/delete/104890/in+docs
Del: other reasons-- https://master.php.net/note/delete/104890
Reject -- https://master.php.net/note/reject/104890
Search -- https://master.php.net/manage/user-notes.php