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

PHP 讀取Postgresql中的數(shù)組

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

復(fù)制代碼 代碼如下:

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中讀取的數(shù)據(jù)都是字符串的,一般的數(shù)據(jù)還好處理,但是postgresql有一種數(shù)組型的數(shù)據(jù),而如果我們的數(shù)組是字符串的,前且,里面有逗號(hào)或斜線也是可能的,這就給我們讀取帶來了一定的麻煩,上面的函數(shù)是我奮斗了幾個(gè)小時(shí)寫出來的。盡可能的考慮到了斜線,逗號(hào),引號(hào)的存在。

相關(guān)文章

最新評(píng)論