note 108639 added to ref.pgsql

From: Date: Sun, 13 May 2012 09:52:58 +0000
Subject: note 108639 added to ref.pgsql
Groups: php.notes 
Request: Send a blank email to php-notes+get-187961@lists.php.net to get a copy of this message
A simple conversion for 1D PostgreSQL array data: // ===== //Example #1 (An array of IP addresses): <?php $pgsqlArr = '{192.168.1.1,10.1.1.1}'; preg_match('/^{(.*)}$/', $pgsqlArr, $matches); $phpArr = str_getcsv($matches[1]); print_r($phpArr); } // Output: // Array // ( // [0] => 192.168.1.1 // [1] => 10.1.1.1 // ) // ===== // ===== // Example #2 (An array of strings including spaces and commas): <?php $pgsqlArr = '{string1,string2,"string,3","string 4"}'; preg_match('/^{(.*)}$/', $pgsqlArr, $matches); $phpArr = str_getcsv($matches[1]); print_r($phpArr); } // Output: // Array // ( // [0] => string1 // [1] => string2 // [2] => string,3 // [3] => string 4 // ) // ===== ---- Server IP: 69.147.83.197 Probable Submitter: 96.37.211.24 ---- Manual Page -- http://www.php.net/manual/en/ref.pgsql.php Edit -- https://master.php.net/note/edit/108639 Del: integrated -- https://master.php.net/note/delete/108639/integrated Del: useless -- https://master.php.net/note/delete/108639/useless Del: bad code -- https://master.php.net/note/delete/108639/bad+code Del: spam -- https://master.php.net/note/delete/108639/spam Del: non-english -- https://master.php.net/note/delete/108639/non-english Del: in docs -- https://master.php.net/note/delete/108639/in+docs Del: other reasons-- https://master.php.net/note/delete/108639 Reject -- https://master.php.net/note/reject/108639 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#187961) next »