2012年12月12日水曜日

開発環境

『初めてのPHP5』 (David Sklar 著、 桑村 潤 翻訳、 廣川 類 翻訳、 オライリー・ジャパン、2005年、ISBN978-4-87311-257-2)の4章(配列の操作)4.7(演習問題)1を解いてみる。

1.

HTML、CSS、PHPのソースコード(TextWrangler)

sample89.php

<style>
  table{
    table-layout:fixed;
    width: 250px;
  }
  .city{
    width:150px;
  }
  .city_row{
    text-align:left;
  }
  .people_row{
    text-align:right;
  }
</style>

<?php
  $population = array(
    "New York, NY" => 8008278,
    "Los Angeles, CA" => 3694820,
    "Chicago, IL" => 2896016,
    "Houston, TX" => 1953631,
    "Philadelphia, PA" => 1517550,
    "Phoenix, AZ" => 1321045,
    "San Diego, CA" => 1223400,
    "Dallas, TX" => 1188580,
    "San Antonio, TX" => 1144646,
    "Detroit, MI" => 951270);
  print '<table border=1><caption>アメリカの都市と人口</caption>';
  print '<tr><th class="city">都市</th><th class="people">人口</th></tr>';
  foreach($population as $city => $people){
    print '<tr><td class="city_row">' . $city . '</td><td class="people_row">' . $people . '</td></tr>';
  }
  print '</table>';
?>

0 コメント:

コメントを投稿