Copy Code code 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 read in PHP from the PostgreSQL is a string, the general data is fine, but PostgreSQL has an array of data, and if our array is a string, before and, there are commas or slashes is also possible, which gives us a certain amount of trouble reading, The above function was written by me for a few hours. Consider, as far as possible, the existence of slashes, commas, quotes.