change pgsql array problem

This commit is contained in:
wlx 2015-01-05 06:50:16 +00:00
parent 8b3828b287
commit 109d194b34
1 changed files with 23 additions and 5 deletions

View File

@ -131,9 +131,11 @@ class Doi extends Zend_Controller_Plugin_Abstract
$orgs_en = array(); $orgs_en = array();
foreach($data['info'] as $k=>$v) foreach($data['info'] as $k=>$v)
{ {
$authors_en[$v['order']] = str_replace(",","",$v['author_en']); $authors_en[(int)$v['order']] = str_replace(",","||||",$v['author_en']);
$orgs_en[$v['order']] = str_replace(",","",$v['organization_en']); $orgs_en[(int)$v['order']] = str_replace(",","||||",$v['organization_en']);
} }
ksort($authors_en);
ksort($orgs_en);
//$authors = "{".join(",",$authors)."}"; //$authors = "{".join(",",$authors)."}";
//$orgs = "{".join(",",$orgs)."}"; //$orgs = "{".join(",",$orgs)."}";
$authors_en = "{".join(",",$authors_en)."}"; $authors_en = "{".join(",",$authors_en)."}";
@ -152,8 +154,8 @@ class Doi extends Zend_Controller_Plugin_Abstract
foreach($authors_en as $k=>$v) foreach($authors_en as $k=>$v)
{ {
$info[$k] = array( $info[$k] = array(
'author_en'=>str_replace("\"","",$authors_en[$k]), 'author_en'=>str_replace("||||",",",str_replace("\"","",$authors_en[$k])),
'organization_en'=>str_replace("\"","",$orgs_en[$k]), 'organization_en'=>str_replace("||||",",",str_replace("\"","",$orgs_en[$k])),
'order'=> count($authors_en)+($k-1) 'order'=> count($authors_en)+($k-1)
); );
} }
@ -166,7 +168,23 @@ class Doi extends Zend_Controller_Plugin_Abstract
/*$a = str_replace("{",'',$a); /*$a = str_replace("{",'',$a);
$a = str_replace("}",'',$a); $a = str_replace("}",'',$a);
$a = explode(",",$a); */ $a = explode(",",$a); */
return explode(',',substr($a,1,-1)); //return explode(',',substr($a,1,-1));
$regx1 = '/^{(.*)}$/';
$regx2 = "/\"((\\\\\\\\|\\\\\"|[^\"])+)\"|[^,]+/";
$regx3 = '/^[^"].*$|^"(.*)"$/';
$match = null;
preg_match( $regx1,$a,$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;
} }
function view($id) function view($id)