2017-11-09 14 views
0

私は私が間違ってすべてを説明し、別の質問を排除し、私はこれはそれぞれのキーで配列の結果を取得する方法は?

、より具体的であると思います、私は同様の質問を見ましたが、この場合は、私はその配列の各値のためにそれを必要とする特定の何か

です私は結果をそれぞれのキー([264]、[265]など)で返します。

私はこの配列があります。

array(2) { 
    [264]=> 
    string(38) "64,74,103,102,101,100,23,13,3,89,88,87"  //the value that I need to pass as a parameter 
    [265]=> 
    string(29) "65,95,96,97,83,84,88,62,54,44"    //the value that I need to pass as a parameter 
} 

私の機能:私の関数の

function ArrayData($id){ 

    foreach($id as $singleId){ 

    $Data[][key($id)] = getData($singleId); //here I pass the value as parameter 

    } 


} 

/** 
* get the result data 
* 
* @return {array} $id 
*/ 
function getData($singleId){ 
    $result = fetchData($singleId);    //here i get the result of the value 
    $decode = json_decode($result, true); 

    return $decode; 
} 

結果:

array(2) { 
    [0]=> 
    array(1) { 
    [264]=> 
    array(11) { 
     [0]=> 
     array(5) { 
     ["id"]=> 
     string(2) "64" 
     ["concepto"]=> 
     string(27) "IIBB Contribuyentes Locales" 
     ["impuesto"]=> 
     string(10) "Anticipo10" 
     ["agencia"]=> 
     string(4) "ARBA" 
     ["vencimiento_del_mes"]=> 
     string(10) "2017-11-21" 
     } 
    } 
    } 
    [1]=> 
    array(1) { 
    [264]=>     //[this has to be 265] 
    array(5) { 
     [0]=> 
     array(5) { 
     ["id"]=> 
     string(2) "65" 
     ["concepto"]=> 
     string(27) "IIBB Contribuyentes Locales" 
     ["impuesto"]=> 
     string(10) "Anticipo10" 
     ["agencia"]=> 
     string(4) "ARBA" 
     ["vencimiento_del_mes"]=> 
     string(10) "2017-11-22" 
     } 
    } 
    } 
} 

配列が

答えて

1
同じキーを持つ両方の結果を示しているが

それはかなりcですあなたはこれが欲しいと思います:

function ArrayData($id){ 

    foreach($id as $key=>$singleId){ 

    $Data[][$key] = getData($singleId); //here I pass the value as parameter 

    } 


} 
関連する問題