php随机丢失数组条目

Following an SQL call, php is storing a 2D assoc array with a list of services. I'm then splitting this into two different arrays (one for services that match a "friendly" name (i.e; predefined service), and another for unspecified services.

During this process, php seems to be randomly throwing out array entries - before the split even begins.

Code:

        $tmp_results_friendly = array();
        $tmp_results_uncategorised = array();
        foreach ($results as $result) {
            //var_dump($result);
            if ((int)$result['friendly_service_id'] != 0) {
                $tmp_results_friendly[] = $result;
            } else {
                $tmp_results_uncategorised[] = $result;
            }
        }

At the point of the commented-out var_dump, entries can go missing at random. A var_dump of $result will show everything. It's typically services that have a friendly_id which is not equal to 0 which go missing.

There are no duplicates in the array, nor is there any over-writing of entries in there. a var_dump just before the foreach loop will return everything - but it seems to just straight out vanish when we enter the foreach loop.

I'm at a loss as to what could cause this - does anyone have any idea?

Edit: added additional code to check array length;

        $tmp_results_friendly = array();
        $tmp_results_uncategorised = array();
        echo "<br/>Results count is: " . count($results);
        $i = (int) 0;
        foreach ($results as $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 from this;

Results count is: 17
Counted in foreach is: 16

I also serialised the arrays before, and after the foreach; prior to the foreach, again we're seeing 17 results. After, 16. One is going missing - no change in structure, format, no special characters, or otherwise.