note 54907 added to function.pg-escape-string

From: Date: Tue, 19 Jul 2005 12:38:00 +0000
Subject: note 54907 added to function.pg-escape-string
Groups: php.notes 
Request: Send a blank email to php-notes+get-92161@lists.php.net to get a copy of this message
Here's some code I knocked up to turn an array of values into a string representation of an array. Note that I also add the external single quotes to make it a full string literal. //$t is array to be escaped. $u will be string literal. $tv=array(); foreach($t as $key=>$val){ $tv[$key]="\"" . str_replace("\"",'\\"', str_replace('\\','\\\\',$val)) . "\" "; } $u= implode(",",$tv) ; $u="'{" . pg_escape_string($u) . "}'"; There's probably a better way of doing this. That's why I'm posting this here :) ---- Manual Page -- http://www.php.net/manual/en/function.pg-escape-string.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+54907 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+54907&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+54907&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+54907&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+54907&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+54907&report=yes&reason=non-english Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+54907&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+54907&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#92161) next »