title: Callback function not found while it is defined above
body: <p>I have this code snippet that is supposed to find the differences between two arrays of feed items:</p>
  
  <pre><code>protected function execute()
  {
      $existingFeedItems = $feed-&gt;getItems();
      $newFeedItems = $feed-&gt;loadItems();
  
      function compareFeedItemIds($feedItem1, $feedItem2)
      {
          return $feedItem1-&gt;getFeedItemId() == $feedItem2-&gt;getFeedItemId() ? 0 : -1;
      }
  
      $feedItemsAdded = array_udiff($newFeedItems, $existingFeedItems, "compareFeedItemIds");
      $feedItemsRemoved = array_udiff($existingFeedItems, $newFeedItems, "compareFeedItemIds");
      $unchangedFeedItems = array_uintersect($newFeedItems, $existingFeedItems, "compareFeedItemIds");
  }
  </code></pre>
  
  <p>This will throw the error:</p>
  
  <blockquote>
    <p>Warning: array_udiff() expects parameter 3 to be a valid callback,
    function 'compareFeedItemIds' not found or invalid function name</p>
  </blockquote>
  
  <p>Even though I have defined that function above. What is the reason for PHP throwing this error? I have to add I am executing this from an object's method context.</p>