PHP Exercises : Display string, values within a table

PHP : Exercise-13 with Solution

Write a e PHP script to display string, values within a table.

Note : Use HTML table elements into echo.

Sample Solution: -

PHP Code

echo "<table border=1 cellspacing=0 cellpading=0>
<tr> <td><font color=blue>Salary of Mr. A is</td> <td>$a$</font></td></tr> 
<tr> <td><font color=blue>Salary of Mr. B is</td> <td>$b$</font></td></tr>
<tr> <td><font color=blue>Salary of Mr. C is</td> <td>$c$</font></td></tr>

Sample Output:

php table

View the output in the browser


Flowchart: Display string, values within a table

Have another way to solve this solution? Contribute your code (and comments) through Disqus.

Previous: Write a simple PHP program to check that emails are valid.
Next: Write a PHP script to display source code of a webpage (e.g. "http://www.example.com/").

What is the difficulty level of this exercise?

Test your Programming skills with w3resource's quiz.

Follow us on Facebook and Twitter for latest update.

PHP: Tips of the Day

Mutates the original array to filter out the values specified


function tips_pull(&$items, ...$params)
  $items = array_values(array_diff($items, $params));
  return $items;

$items = ['x', 'y', 'z', 'x', 'y', 'z'];
print_r(tips_pull($items, 'y', 'z'));


    [0] => x
    [1] => x