title: PHP function always returns same value
body: <p>I am using Wordpress post 2 post plugin to connect actors to films. Trying to display actor info including his films(ID's).</p>
  
  <p>Each time function runs, the $value variable is always different number, but somehow function result always is the same.</p>
  
  <p><strong>$result</strong> always creates empty array, when function runs.
  <strong>$variable</strong> is different each time, that means <strong>$post_val</strong> is also different each time function runs, same for <strong>$list</strong> and <strong>$post</strong>.</p>
  
  <p>I have no idea what's is wrong with my code then.</p>
  
  <pre><code>function get_connected_values($value) {
      $post_val = get_post($value);
      $related = p2p_type( 'actors_to_films' )-&gt;get_connected($post_val);
      $list = $related-&gt;posts;
      $result = [];
      foreach ($list as $post) {
          array_push($result, $post-&gt;ID);
      }   
      if (empty($result)) {
          return '';
      } else {
          $res = implode(",", $result);
          return $res; //always returns same, smt like 1111,1113,1114
      }
  }   
  </code></pre>