title: Creating & Referencing PHP Variables from foreach to compare
body: <p><a href="http://donedigital.com.au/trello.php" rel="nofollow">Live page can be seen here</a></p>
  
  <p>I'm aiming to apply a specific class to each list item in the second UL based upon the list it appears on. The second json call returns an ID that matches the ID and name pair which can be found in the first list.</p>
  
  <p>I'd like to have each listID assigned to a $variable called $listID with the value that is the name of that list.</p>
  
  <p>eg <code>$514fc8993f53cfb366006851 = "To Do";</code></p>
  
  <p>I could then use an if statement to assign a class based upon a series of if statements in the second block of PHP.</p>
  
  <p>Any help generating these variables would be greatly appreciated.</p>
  
  <p>The relevant code is as follows: </p>
  
  <pre><code>&lt;p&gt;The sample board contains the following lists:&lt;/p&gt;
  &lt;ul&gt;
      &lt;?
          $lists_enc = file_get_contents("https://api.trello.com/1/board/".$BOARD."/lists?key=9ee57574e9f968cedf9ac9964d2f7c4e");
          $lists = json_decode($lists_enc, true);
          $testing = array();
  
          foreach ($lists as $list) {
              $id = $list["id"];
              $name = $list["name"];
  
              echo "&lt;li&gt;".$name." (".$id.")&lt;/li&gt;\n";
          }
          echo "&lt;/ul&gt;";
      ?&gt;
  
  &lt;p&gt;The sample board contains the following cards:&lt;/p&gt;
  &lt;ul&gt;
      &lt;?
          $cards_enc = file_get_contents("https://api.trello.com/1/board/".$BOARD."/cards?fields=name,idList&amp;key=9ee57574e9f968cedf9ac9964d2f7c4e");      
          $cards = json_decode($cards_enc, true);
  
          foreach ($cards as $card) {
          echo "&lt;li class=".$status."&gt;".$card["name"]."&lt;/li&gt;\n";
        }  
  
      ?&gt;
  &lt;/ul&gt;
  </code></pre>