php - Count on recursive array search has strange behavior -
I need to count how many values are in multi-dimensional array and update the count value.
But I get a strange behavior, because only a few values are counted, others are repeated.
Code here:
Edit Code here:
function recursive_array_search ($ needle, $ haystack) {foreign Currency ($ haystack = & gt; $ value as the $ key) {$ current_key = $ key; If ($ needle === $ value || (is_array ($ value) & amp; amp; amp; & amp; recursive_array_search ($ needle, $ value)! == incorrect)) Return $ $ current_key; } } return false; } $ Area = array ('emilia romagna', 'abruzo', 'Lombardia', 'emilia romagna', 'abrazo', 'abrajo'); $ Area = array ('bologna', 'bolonano', 'milano', 'bologna', 'bologna'); $ Data field = array (); $ Datability = array (); Foreign currency ($ area as result of $) {if ($ key = recursive_array_search ($ result, $ data region)) {$ data region [$ key] ['count'] ++; } Else {$ dataRegion [] = array ('type' = & gt; 'field', 'label' = & gt; $ result, 'calculation' => 1;); }} Foreach ($ area as $ result) {if ($ key = recursive_array_search ($ result, $ datelokytyty)) {$ Datalatie [$ key] ['count'] ++; } Else {$ dataLocality [] = array ('type' = & gt; 'locality', 'label' = & gt; $ result, 'calculation' => 1;); }} Print_r ($ dataarity); Echo & lt; Br / & gt; ==================== & lt; Br / & gt; '; Print_r ($ dataRegion);
Why can not I really explain this behavior
Comments
Post a Comment