I have a list of phone numbers from 2 companies. If company A has a phone number in the same city and state as Company B, I want to hide the phone number from Company B in the list.

How would I accomplish this? How do I access and check against the rest of the rows in the query?

Comments

bcreeves’s picture

This is what I have tried for my filter code but it doesn't seem to do anything:

<?php
if (isset($row->field_company_b)) {
  if (in_array($row->field_phone_number_city, $cities)) {
    return true;
  }
} else {
  $cities[] = $row->field_phone_number_city;
  return false;
}
?>

I'm displaying company A first and keeping an array of the cities. Then when it gets to company b in the sort I'm checking to see if its city is in the cities array and if so not displaying that row.

But again, this doesn't seem to do anything. Will the array variable not maintain itself from row to row? Am I doing something wrong?