欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

PHP 讀取Postgresql中的數(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ù)組是字符串的,前且,里面有逗號或斜線也是可能的,這就給我們讀取帶來了一定的麻煩,上面的函數(shù)是我奮斗了幾個小時寫出來的。盡可能的考慮到了斜線,逗號,引號的存在。

相關(guān)文章

最新評論