亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

PHP 讀取Postgresql中的數組

 更新時間:2013年04月14日 11:34:42   作者:  
PHP 讀取Postgresql中的數組,需要的朋友可以參考一下

復制代碼 代碼如下:

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;
 }

在PHP從postgresql中讀取的數據都是字符串的,一般的數據還好處理,但是postgresql有一種數組型的數據,而如果我們的數組是字符串的,前且,里面有逗號或斜線也是可能的,這就給我們讀取帶來了一定的麻煩,上面的函數是我奮斗了幾個小時寫出來的。盡可能的考慮到了斜線,逗號,引號的存在。

相關文章

最新評論