echo $path; //working function createList($retval) { echo $path; //not working print \"
Cause $path inside createList() and outside it (in global scope) are two different variables. Read more about variable scope in PHP.
$path
createList()