A
Anonymous
Guest
Hi,
For some XML parsing purposes, I need a reference to somewhere in an associative array. I have created this method:
(ofcourse the echoing here is only for debugging purposes)
I want to call it using:
$hashMap =& pathMapping("/somekey/more/and/finally/");
Which should return a refference to:
$this->parsedData{"somekey"}{"more"}{"and"}{"finally"}
Apparently, eval("return $something;"); doesn't actually return the $something as result of the function. I can see the "?" being echoed which it shouldn't if the value was returned (return exists the function).
I've tried this format too: return eval("return $something;"); but since I want to return a reference, I get the "Only variable references should be returned by reference" error.
Apart from itterations (which are slower), is there a way to return the result of an eval as reference?
Rgds,
Coditor
For some XML parsing purposes, I need a reference to somewhere in an associative array. I have created this method:
Code:
function &pathMapping() {
if ($this->path > "/") {
echo "returning...<br />";
eval('return $this->parsedData{"' . implode('"}{"', preg_split("!/!", $this->path, -1, PREG_SPLIT_NO_EMPTY)) . '"};');
echo "?<br />";
}
return $this->parsedData;
}
I want to call it using:
$hashMap =& pathMapping("/somekey/more/and/finally/");
Which should return a refference to:
$this->parsedData{"somekey"}{"more"}{"and"}{"finally"}
Apparently, eval("return $something;"); doesn't actually return the $something as result of the function. I can see the "?" being echoed which it shouldn't if the value was returned (return exists the function).
I've tried this format too: return eval("return $something;"); but since I want to return a reference, I get the "Only variable references should be returned by reference" error.
Apart from itterations (which are slower), is there a way to return the result of an eval as reference?
Rgds,
Coditor