How can I display user data in columns and rows in PHP?

To display user data in columns and rows in PHP, you can use HTML table tags within your PHP code. You can fetch the user data from a database or any other data source and then loop through the data to create rows and columns in the table.

<?php
// Sample user data
$users = array(
    array('John Doe', 'john.doe@example.com', 'New York'),
    array('Jane Smith', 'jane.smith@example.com', 'Los Angeles'),
    array('Mike Johnson', 'mike.johnson@example.com', 'Chicago')
);

// Display user data in a table
echo '<table border="1">';
echo '<tr><th>Name</th><th>Email</th><th>City</th></tr>';
foreach ($users as $user) {
    echo '<tr>';
    foreach ($user as $data) {
        echo '<td>' . $data . '</td>';
    }
    echo '</tr>';
}
echo '</table>';
?>