assuming your form looks vaguely like the following:
HTML Code:
<form action='scramble.php' method='post'>
<textarea name='words'></textarea>
<input type='submit' value='Scramble!'>
</form>
then the following should work (I've included comments so you see what I'm doing and why, and hopefully you'll understand how it works
):
scramble.php
PHP Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Word Scrambler Results</title>
<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'>
</head>
<body>
<?php
if (isset($_POST['words']))
$words_s = $_POST['words'];
else
die ('Give me a list of words, separated by a comma. <a href="http://forums.x10hosting.com/programming-help/index.html">Go back</a></body></html>');
$words_s = trim($words_s);
// we don't want spaces or anything like that in the words, so we use trim to get rid of whitespace.
$words_a = explode(',',$words_s);
// explode will convert a string into an array, with the first parameter being the delimiter.
echo "<p>\n";
foreach ($words_a as $word) // foreach will iterate through the array, with each value being assigned to the variable $word.
{ // this is what we do for each array value.
$word = str_shuffle($word); // str_shuffle simply reorders the characters in a string.
echo "$word<br>\n";
}
?><br>
There are no more words left to scramble!</p>
</body></html>