Copy codeThe 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;
}
The data read from postgresql in PHP is string, and the general data is still well processed. However, postgresql has an array type of data. If our array is string, it is also possible to have a comma or slash in it, which makes reading a lot of trouble. The above function was written by me after several hours. We try to consider the existence of diagonal lines, commas, and quotation marks.