Posted by: Sourav | April 4, 2011

Presenting data in a table format from an array


<html>
    <head>
        <title>
            Presenting data in a table layout
        </title>
    </head>
    <body>
        <?php
        $array=array(‘India’=>’New Delhi’,’Pakistan’=>’Islamabad’,’Sri Lanka’=>’Colombo’,
                     ‘Nepal’=>’Katmandu’,’Kenya’=>’Nairobi’);
        echo “<center>”;
        echo “<Table border=\”1\”>”;
        echo “<TR>”;
        echo “<TH>Countries</TH>”;
        echo “<TH>Capitals</TH>”;
        echo “</TR>”;
         reset($array);
        while(list($key,$value)=each($array))
        {
            echo “<TR>”;
        echo “<TH>$key</TH>”;
        echo “<TH>$value</TH>”;
        echo “</TR>”;
           
        }
        echo “</center>”;
       
       
        ?>
       
    </body>
</html>

   

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: