Live page can be seen here創建和從引用的foreach PHP變量比較
我的目標到具體的類別應用到基於它出現在列表中第二UL每個列表項。第二個json調用返回一個ID,該ID匹配可以在第一個列表中找到的ID和名稱對。
我想將每個listID分配給一個名爲$ listID的$變量,其值是該列表的名稱。
如$514fc8993f53cfb366006851 = "To Do";
然後我可以使用if語句來分配基於一系列的類,如果在PHP中的第二塊語句。
任何幫助生成這些變量將不勝感激。
相關的代碼如下:
<p>The sample board contains the following lists:</p>
<ul>
<?
$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 "<li>".$name." (".$id.")</li>\n";
}
echo "</ul>";
?>
<p>The sample board contains the following cards:</p>
<ul>
<?
$cards_enc = file_get_contents("https://api.trello.com/1/board/".$BOARD."/cards?fields=name,idList&key=9ee57574e9f968cedf9ac9964d2f7c4e");
$cards = json_decode($cards_enc, true);
foreach ($cards as $card) {
echo "<li class=".$status.">".$card["name"]."</li>\n";
}
?>
</ul>
目標是從這個json創建3個變量 - https://api.trello.com/1/board/ 514fc8993f53cfb366006850 /列表?關鍵= 9ee57574e9f968cedf9ac9964d2f7c4e ,讓我的ID(包含在其他的JSON輸出)的名稱(這是隻有在這個JSON輸出) – 2013-03-25 23:48:08