Advertisement
academ1c

Users

Jul 3rd, 2013
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.80 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4.     <title>Users</title>
  5. </head>
  6. <body>
  7.  
  8. <style>
  9. table, tr, th, td {
  10.     border: 1px dotted #000;
  11.     border-collapse: collapse;
  12.     padding: 5px 10px 5px 10px;
  13. }
  14. </style>
  15.  
  16. <?php
  17. $usernames = array("John", "Jack", "Anna", "Ray", "Richard");
  18. $emails = array("john.d@example.com", "jack.r@hotmail.com", "anna.a@example.org", "ray@ray.org", "richard@richard.net");
  19. ?>
  20.  
  21. <?php
  22. if(count($usernames) !== count($emails) || empty($usernames) && empty($emails))
  23. {
  24.     echo "The array either are empty or values do not match.";
  25.     die();
  26. }
  27. ?>
  28.  
  29. <table>
  30.     <tr>
  31.         <th>Username</th>
  32.         <th>Email</th>
  33.     </tr>
  34. <?php foreach(array_combine($usernames, $emails) as $username => $email) { ?>
  35.     <tr>
  36.         <td><?php echo $username; ?></td>
  37.         <td><?php echo $email; ?></td>
  38.     </tr>
  39. <?php } ?>
  40. </table>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement