PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I have created a function that accepts two arguments a first and a last name. the function returns the initials in a single string. I need to call the above function 5 times, passing in 5 different names and print the value returned each time. I can't figure out how to loop the function 5 times so the user can enter a different name each time and it print out each of the five names' initials. here's what i have so far.
index.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Functions!</title>
</head>
<body>
<p>Please enter your first and last name so I can
give you your initials.</p>
<form action="functions.php" method="post">
<p>First Name: <input type="text" name="first_name" size="20" /></p>
<p>Last Name: <input type="text" name="last_name" size="20" /></p>
<input type="submit" name="submit" value="Get My Initials" />
</form>
</body>
</html>
Rather than having the form action point to functions.php, I'd have it point to itself (or just leave it blank) and have the page execute the function whenever the form is submitted.