[Solved] Php Array to Table Rows


Whatever you used in your print_r is what I’m focusing on here for this solution. So if you did print_r($_POST) then this would work:

I use htmlspecialchars to clean the string to prevent nasty xss injections.

<?php

foreach($_POST as $row) {
    $part = htmlspecialchars($row[0], ENT_QUOTES, 'UTF-8');
    $rel = htmlspecialchars($row[1], ENT_QUOTES, 'UTF-8');
    $chart = htmlspecialchars($row[2], ENT_QUOTES, 'UTF-8');
    $dob = htmlspecialchars($row[3], ENT_QUOTES, 'UTF-8');
    $age = htmlspecialchars($row[4], ENT_QUOTES, 'UTF-8');
    $gender = htmlspecialchars($row[5], ENT_QUOTES, 'UTF-8');
    $unkown = htmlspecialchars($row[6], ENT_QUOTES, 'UTF-8'); //your output shows a [6]'th element

    $participants_table = "<tr><td>". $part . "</td><td>". $rel ."</td><td>". $chart ."</td><td>". $dob ."</td><td>". $age ."</td><td>". $gender ."</td></tr>";

}

What’s most interesting to me is that in your datadump, there’s no associative keys, hence why numerical keys are used instead

2

solved Php Array to Table Rows