PHP read the array _php tutorial in PostgreSQL

Source: Internet
Author: User
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 ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.