title: PHP get variable from function
body: <pre><code>function first() {
      foreach($list as $item ) {
          ${'variable_' . $item-&gt;ID} = $item-&gt;title;
          // gives $varible_10 = 'some text'; (10 can be replaced with any number)
      }
      $ordinary_variable = 'something';
  }
  </code></pre>
  
  <p>How to get values of this function inside an another function?</p>
  
  <p>Like:</p>
  
  <pre><code>function second() {
      foreach($list as $item ) {
          get ${'variable_' . $item-&gt;ID};
          // getting identical value from first() function
      }
      get $ordinary_variable;
  }
  </code></pre>
  
  <ul>
  <li>We know that <code>$variable_id</code> (id is numeric) already exists in <code>first()</code></li>
  <li><code>$list</code> is an <code>Array()</code>, which can have more than 100 values.</li>
  <li><code>$ordinary_variable</code> is a string.</li>
  </ul>
  
  <p>Thanks.</p>