php randomly losing array entries -
following sql call, php storing 2d assoc array list of services. i'm splitting 2 different arrays (one services match "friendly" name (i.e; predefined service), , unspecified services.
during process, php seems randomly throwing out array entries - before split begins.
code:
$tmp_results_friendly = array(); $tmp_results_uncategorised = array(); foreach ($results $result) { //var_dump($result); if ((int)$result['friendly_service_id'] != 0) { $tmp_results_friendly[] = $result; } else { $tmp_results_uncategorised[] = $result; } }
at point of commented-out var_dump, entries can go missing @ random. var_dump of $result show everything. it's typically services have friendly_id not equal 0 go missing.
there no duplicates in array, nor there over-writing of entries in there. var_dump before foreach loop return - seems straight out vanish when enter foreach loop.
i'm @ loss cause - have idea?
edit: added additional code check array length;
$tmp_results_friendly = array(); $tmp_results_uncategorised = array(); echo "<br/>results count is: " . count($results); $i = (int) 0; foreach ($results $result) { //var_dump($result); $i++; if ((int)$result['friendly_service_id'] != 0) { $tmp_results_friendly[] = $result; } else { $tmp_results_uncategorised[] = $result; } } echo "<br/>counted in foreach is: {$i}";
results this;
results count is: 17 counted in foreach is: 16
i serialised arrays before, , after foreach; prior foreach, again we're seeing 17 results. after, 16. 1 going missing - no change in structure, format, no special characters, or otherwise.
Comments
Post a Comment