Hello,
I am splitting the variables from the global array $_POST with each() and list() and assigning separate variables from the split.
However, after assigning global variables once within a function using each()/list(), you can't do it again in another function. See example below:
Am I missing something? Shouldn't you be able to split the $_POST array anytime, anywhere, and any number of times?
Someone please advise. Thank you.
EXAMPLE:
<form method="post">
<input type="text" name="field1" value="foo">
<input type="text" name="field2" value="bar">
<input type="submit">
</form>
<?php
split1();
split2();
function split1() {
echo "FIRST SPLIT RESULTS<BR>";
while( list($key, $value) = each($_POST) )
{
$$key = trim($value);
echo "$$key , $value<br>";
}
}
function split2() {
echo "<P>SECOND SPLIT RESULTS<BR>";
while( list($key, $value) = each($_POST) )
{
$$key = trim($value);
echo "$$key , $value<br>";
}
}
?>
============================
Ed