php - Three Dimensional Array Changing -
i'm calling 3 dimension array api, after different calls api data different, array keys change. example first array may relate type 1 in 1 case, whereas in case relates type two. it's laid out
array ( [id] => [stats] => array ( [0] => array ( [type] => [option] => [modifydate] =>
as stated before relates different types, there way of getting array based on inside of it, example if "type" in first array equals type 1 assign variable type1?
perhaps in better example, in scenario 1 shows this:
array ( [summonerid] => 39562006 [playerstatsummaries] => array ( [0] => array ( [playerstatsummarytype] => aramunranked5x5 [wins] => 4 [modifydate] => 1481110651000 [aggregatedstats] => array ( [totalchampionkills] => 48 [totalturretskilled] => 2 [totalassists] => 171 ) )
whereas in scenario 2 shows
array ( [summonerid] => 34951469 [playerstatsummaries] => array ( [0] => array ( [playerstatsummarytype] => cap5x5 [wins] => 16 [modifydate] => 1481117277000 [aggregatedstats] => array ( [totalchampionkills] => 325 [totalminionkills] => 1996 [totalturretskilled] => 26 [totalneutralminionskilled] => 1048 [totalassists] => 298 ) )
after trial , error myself think foreloop iterate each array , output chosen keys array i'm still unsure on how this, suggestions?
my advice similar answer: https://stackoverflow.com/a/42708457/2943403 unfortunately, cannot give more detailed information without small relevant samples of related input arrays , desired output array.
// $new=array(...); // $old=array(...); foreach($new $new_key=>$new_subarray){ foreach(array_diff_key($old,range(0,$new_key)) $old_subarray){ // no dupe loops // perform checks between $new_subarray , $old_subarray } }
Comments
Post a Comment