php - fill an array with missing values and keys -


I have this array $ all_zones which sometimes comes with the missing keys and values And I want to fill the array with empty values ​​for disturbing keys, here's the array:

Array ([0] => Array ([id_zone] = & gt; 1 [ Name] => Europe [value] = & gt; Array ([0] => 3.00 [1] => 6.00) [ID_delivery] => Hey ([0] => 1 [1] ] = [2]) [1] = Array ([id_zone] => 3 [name] => gt; [2] = & gt; Array ([id_jon] => 4 [name ] = & Gt; Africa [value] => array ([0] => 3.00 [1] => 6.00) [I ___blivar y] => Array ([0] => 3 [1] => 4)) [3] = Array ([id_zone] => 5 [name] = & gt; ; Oceania))

This is $ all_zones [$ key] ['price'] on how many categories for each region Depending on this, in this case $ range_count = count ($ all_ranges); will display 2 , so I'd like to fill the missing keys for ' 2 : Here's the output:

  Array ([0] => array ([id_zone] => 1 [name] => Europe [value] => Array ([0] => 3.00 [1] => ; 6.00) [id_delivery] => Hey ([0] => 1 [1] => 2)) [1] => Array ([id_jon] => 3 [name] => Asia [value] = & gt; Hey ([0] => [1] = & gt;) [ID_delivery] => Array ([0] => [1] = & gt; )) [2] = & gt; Array ([id_zone] = & gt; 4 [name] => Africa [value] => Array ([0] => 3.00 [1] = & gt; ; 6.00) [id_delivery] = & gt; array ([0] = & gt ; 3 [1] = & gt; 4)) [3] => Array ([id_zone] => 5 [name] = & gt; Oceania [value] => Array ([0] = & Gt; [1] = & gt;) [id_delivery] = & gt; Hey ([0] = & gt; [1] = & gt;)))  

Even here That I have tried so far and have not succeeded:

range_count = count ($ all_ranges); $ I = =; Foreign currency ($ all_zones $ key = & gt; $ value) {if (isset ($ value ['id_zone']) and isset ($ value ['name']) & amp; (! Isset ($ value) ['Value']) .set ($ value ['id_delivery'])) {if ($ range_count> $ i) {$ disabled [] = $ key; $ All_zones [$ key] ['value'] [] = ''; $ All_zones [$ key] ['id_delivery'] [] = '; } $ I ++; }}

Any help with this? much appreciated.

try this

  $ range_count = count ($ all_ranges) ; Foreign currency ($ all_zones $ key = & gt; $ value) {if (isset ($ value ['id_zone']) and isset ($ value ['name']) & amp; (! Isset ($ value) ['Value']) | | isset ($ value [id_delivery ']))) {$ disabled [] = $ key; If ($ ([$ value ['price'])) {for ($ i = 0; $ i & lt; $ range_count & lt; $ i ++) {$ all_zones [$ key] ['id_delivery'] [ ] = '';}} For ['$ Id_delivery']) {$ i = 0; $ I & lt; $ Range_count & lt; $ I ++} {$ all_zones [$ key] ['id_delivery'] [] = '';}}}}  

Comments

Popular posts from this blog

Member with no value in F# -

java - Joda Time Interval Not returning what I expect -

c# - Showing a SelectedItem's Property -