echo $path; //working function createList($retval) { echo $path; //not working print \"
As an alternative to using a global variable, just pass $path in. Of course, if you don't need the variable inside the function, don't bother!
$path
echo $path; function createList($retval, $path) { echo $path; print ""; foreach ($retval as $value) { print "$value"; } print ""; print ""; }