Copy CodeThe code is as follows:
function Getarray_postgresql ($ARRAYSTR)
{
$REGX 1 = '/^{(. *)}$/';
$REGX 2 = "/\" ((\\\\\\\\|\\\\\ "|[ ^\"])+)\"| [^,]+/";
$REGX 3 = '/^[^ '].*$|^ "(. *)" $/";
$match = null;
Preg_match ($regx 1, $arraystr, $match);
$STR = $match [1];
Preg_match_all ($regx 2, $str, $match);
$items = $match [0];
$array = Array ();
$count = count ($items);
for ($index = 0; $index < $count; + + $index)
{
Preg_match ($regx 3, $items [$index], $match);
$array [$index]=end ($match);
}
return $array;
}
The data that PHP reads from PostgreSQL are strings, the general data is good to handle, but PostgreSQL has an array of data, and if our array is a string, before and there is a comma or slash is possible, which gives us a certain trouble reading, The above function was written by me for a few hours. Consider the existence of a slash, comma, and quotation marks as much as possible.
http://www.bkjia.com/PHPjc/326853.html www.bkjia.com true http://www.bkjia.com/PHPjc/326853.html techarticle Copy the code as follows: function Getarray_postgresql ($arraystr) {$regx 1 = '/^{(. *)}$/'; $regx 2 = "/\" ((\\\\\\\\|\\\\\ |[ ^\"])+)\"| [^,]+/"; $REGX 3 = '/^[^ '].*$|^ "(. *)" $/"; $MATC ...