1

i have this array :

Array
(
    [0] => Array
        (
            [0] => TotalVisits
            [1] => 360
        )

    [1] => Array
        (
            [0] => TotalUnique
            [1] => 246
        )

)

I want diplay it like this :

TotalVisits | TotalUnique | 
---------------------------
360         | 246         | 

Any way i could do that ? Thanks! I tried this :

$fields = array(

        0 => $general[0][0] ,
        1 => $general[1][0] ,
    ) ; 
    echo '<div id="collapse_awstats_extract_sider" class="accordion-body collapse in">';
        echo '<div class="accordion-inner">';
            print_table(array(0 => $general[0],1 => $general[1]), $fields); 
        echo '</div>';
    echo '</div>';

but it displays like this

TotalVisits     TotalUnique
TotalVisits     360
TotalUnique     246
0

1 Answer 1

3

Use foreach loop:

$array = array(array('TotalVisits', 360), array('TotalUnique', 246));
$headers = array($array[0][0], $array[1][0]);
$values = array($array[0][1], $array[1][1]);

echo '<table>';
echo '<tr>';
foreach($headers as $name) {
   echo '<th>' . $name . '</th>';
}
echo '</tr>';
foreach($values as $element) {
   echo '<tr>';
   echo '<td>' . $element . '</td>';
   echo '</tr>';
}
echo '</table>';
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.