|
Posted by David Smithz on 01/15/07 01:07
Is it possible to pass arrays by reference?
Already have a work around for the below by using a foreach instead, but I
am still interested to know why the below did not work as the final array
was always blank despite my debugging output suggesting everything works
inside the function.
The code below uses the array walk function:
function check_if_FV_TES ($value, $key, &$ary_of_FVs) {
echo "<BR>Here we are: $key $value," . substr($key, 0, 6);
if (substr($key, 0, 6)=="FV_TES") {
echo "<BR>We got a match:". substr($key,11);
#Place this key and string into another variable (note we get the part
after 9 characters as the first 9 identify fiel type, actual name starts
then
$ary_of_FVs[substr($key,11)] = $value;
echo "<BR>:here is the array so far:";
print_r($ary_of_FVs);
};
}
#Create a blank array to stor the form variables
$ary_Fulllist_of_FVs = array();
#Call the array walk
array_walk($_REQUEST, 'check_if_FV_INP', $ary_Fulllist_of_FVs );
$ary_Fulllist_of_FVs - always had a blank array at the end.
Any ideas?
Navigation:
[Reply to this message]
|