note 44936 deleted from ref.pgsql by tomsommer

From: Date: Fri, 20 Aug 2004 18:08:00 +0000
Subject: note 44936 deleted from ref.pgsql by tomsommer
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-75011@lists.php.net to get a copy of this message
Note Submitter: phill at kenoyer dot com ---- 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); ?>

« previous php.notes (#75011) next »