PHP error while creating array
I apologize in advance because I am very new to programming and I am in a rush to get this completely as I am working on a deadline this is also my first time using this webpage or virtually any forum.
I need to create a simple array and loop in PHP that stores and prints the name of 3 tennis players.
My code looks like this:
html>
<head>
<title>Tennis Players Array</title>
</head>
<body>
<form action="" method="POST">
<input type="text" name="name">
<input type="submit" value = "submit">
</form>
<p>
<?php
$request = $_SERVER['REQUEST_METHOD'];
$name = $_POST['name'];
if ($request == 'GET')
{
// Do Nothing
}
else if ($request == 'POST')
{
$TennisPlayers = array("Roger Federer", "Rafael Nadal", "Novak Djokovic");
echo $TennisPlayers;
}
?>
</p>
</body>
</html>
I am getting an error when running the code:
"Note: Convert array to string in C: \ xampp \ htdocs \ Problem3 \ ProblemThree.php on line 19"
Line 19
And that probably won't be the only bug if fixed.
Look, I understand you are not going to give me a straight answer to this question, and I appreciate it, although I would really like to help him with that. PS Sorry for such a question, rookie. Thank!:)
+3
source to share
3 answers