note 44936 added to ref.pgsql
| From: | phill at kenoyer dot com | Date: | Fri, 20 Aug 2004 16:22:09 +0000 |
| Subject: | note 44936 added to ref.pgsql | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-75001@lists.php.net to get a copy of this message | ||
Here is some code to convert a PHP array to a Postgresql array. This complements the code I wrote
to convert the Postgresql array to PHP array.
<?php
function phptopg($array = FALSE)
{
if (!$array) return (FALSE);
$pg_array = "{";
foreach ($array as $value)
{
if (is_array($value)) $pg_array .= phptopg($value).',';
else $pg_array .= "$value,";
}
if ($pg_array[strlen($pg_array)-1] == ',') $pg_array = substr($pg_array, 0, -1);
$pg_array = $pg_array.'}';
return ($pg_array);
}
$myarray = array('test1','test2','test3');
print phptopg($myarray);
?>
----
Manual Page -- http://www.php.net/manual/en/ref.pgsql.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+44936
Delete -- http://master.php.net/manage/user-notes.php?action=delete+44936&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+44936&report=yes
Search -- http://master.php.net/manage/user-notes.php