Im trying to understand functions
i turned in my assignment and one of my pages was this
<?
function func2 ()
{
extract($_GET);
if ($string == NULL){
print <<<HERE
<form>Please type some words to get your alphabetized list
<textarea name="string" rows="1" cols="40"></textarea>
<input type="submit" value="submit">
</form>
HERE;
} else {
$words = split(" ", $string);
$theWord = sort($words);
$newphrase = "";
foreach ($words as $theWord){
$newphrase .= $theWord." ";
}
echo "here are you words in aplhabetical order -- $newphrase";
} // end if
}
?>
my teacher resopnded with
Also, to my way of thinking, it would be better if it did not directly access the $_GET array but instead acccepted any array to operate on:
10:function orderWords($vars) {
11:
12: extract($vars);
13:
14: if ($string == NULL){
15:
16: print <<<HERE
17:
18: <form>Please type some words to get your alphabetized list
19: <textarea name="string" rows="1" cols="40"></textarea>
20: <input type="submit" value="submit">
21: </form>
22:
23: HERE;
24:
25: } else {
26:
27: $words = split(" ", $string);
28: $theWord = sort($words);
29: $newphrase = "";
30:
31: foreach ($words as $theWord){
32: $newphrase .= $theWord." ";
33: }
34:
35: return $newphrase";
36:
37: } // end if
38:
39:}
try as i might i don't understand the
code=php {
11:
12: extract($vars);[/code]
at the beginning
and my teacher is not responding
any advice