Copy code The code is as follows:
function getarray_postgresql($arraystr)
{
$regx1 = '/ ^{(.*)}$/';
$regx2 = "/"((\\\\|\\"|[^"])+)"|[^,]+/";
$regx3 = '/^[^"].*$|^"(.*)"$/';
$match = null;
preg_match($regx1,$arraystr,$match);
$str = $match[1];
preg_match_all($regx2, $str,$match);
$items = $match[0];
$array = array();
$count = count($items);
for($index = 0; $index < $count;++$index)
{
preg_match($regx3, $items[$index] ,$match);
$array[$index]=end($match);
}
return $array;
}
in PHP from postgresql The data read are all strings, and general data is easy to process, but postgresql has an array type of data, and if our array is a string, it is possible that there are commas or slashes in it. This This brings us some trouble in reading. I struggled for several hours to write the function above, taking into account the existence of slashes, commas, and quotation marks as much as possible.
http://www.bkjia.com/PHPjc/326853.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/326853.htmlTechArticleCopy the code The code is as follows: function getarray_postgresql($arraystr) { $regx1 = '/^{(.*)} $/'; $regx2 = "/"((\\\\|\\"|[^"])+)"|[^,]+/"; $regx3 = '/^[^"].* $|^"(.*)"$/'; $matc...