note 53450 added to function.preg-replace
| From: | daevid at daevid dot com | Date: | Thu, 02 Jun 2005 01:33:36 +0000 |
| Subject: | note 53450 added to function.preg-replace | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-89760@lists.php.net to get a copy of this message | ||
I often times format my SQL queries in a readable way, however when i want to debug, it's not
always desireable to have them formatted, as it often looks goofy and tabs are not right.
Here's a quick way to make the SQL statment all on one single line (insert into your own SQL
wrapper as desired -- you are using a SQL wrapper right?):
<?php
$sql = "SELECT RT.foo, NR.bar
FROM ResultTable RT, NetworkTable NR
WHERE NR.s_id = RT.s_id AND
NR.r_id = RT.r_id AND
RT.IPAddress = NR.ipaddr AND
RT.MAC = NR.MAC";
$sql = preg_replace("/\s+/",' ', (preg_replace("/\s/",'
',$sql)) );
echo "SQL: ".$sql."\n";
?>
----
Manual Page -- http://www.php.net/manual/en/function.preg-replace.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+53450
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+53450&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+53450&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+53450&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+53450&report=yes&reason=useless
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+53450&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+53450&report=yes
Search -- http://master.php.net/manage/user-notes.php