harmor19
07-06-2006, 02:50 AM
I'm sort of copying vBulletin's code that cleans data. If I echo the variable in the function it works but if I return the variable and echo it outside the function it doesn't.
Here is the code.
<?php
function clean($mthd, $arr)
{
if($mthd == "p")
{
foreach (array_keys($arr) as $val)
{
go_clean($val, 'p');
}
}
}
function go_clean(&$val, $mthd)
{
$efinfo = array();
if($mthd == "p")
{
$efinfo[$val] = $_POST[$val];
}
return $efinfo;
//echo "$val: ". $_POST[$val] ."<br /> ";
}
$_POST['username'] = "harmor";
$_POST['password'] = "andrew123";
$data = array('username' => 'STR', 'password' => 'STR', 'age' => 'INT', 'email' => 'STR');
clean('p', $data);
echo $efinfo['username'];
?>
What does the "and" symbol in this function do? go_clean(&$val, $mthd)
I just added it to see if it changed anything but it didn't.
Here is the code.
<?php
function clean($mthd, $arr)
{
if($mthd == "p")
{
foreach (array_keys($arr) as $val)
{
go_clean($val, 'p');
}
}
}
function go_clean(&$val, $mthd)
{
$efinfo = array();
if($mthd == "p")
{
$efinfo[$val] = $_POST[$val];
}
return $efinfo;
//echo "$val: ". $_POST[$val] ."<br /> ";
}
$_POST['username'] = "harmor";
$_POST['password'] = "andrew123";
$data = array('username' => 'STR', 'password' => 'STR', 'age' => 'INT', 'email' => 'STR');
clean('p', $data);
echo $efinfo['username'];
?>
What does the "and" symbol in this function do? go_clean(&$val, $mthd)
I just added it to see if it changed anything but it didn't.