note 13835 deleted from function.extract by jimw

From: Date: Sat, 08 Dec 2001 19:58:17 +0000
Subject: note 13835 deleted from function.extract by jimw
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-22156@lists.php.net to get a copy of this message
Note that the insert symbols are copies and not references of the original array. Here's some sample code to show: $arr['variablex'] = 5; extract($arr); $variablex = 6; print_r($variablex); print_r($arr['variablex']); unset($variablex); reset($arr); list($k,$v) = each($arr); $$k =& $v; $variablex = 7; print_r($variablex); print_r($arr['variablex']); unset($variablex); reset($arr); list($k,$v) = each($arr); $$k =& $arr[$k]; $variablex = 8; print_r($variablex); print_r($arr['variablex']); unset($variablex); reset($arr); list($k,$v) = each($arr); eval('$' . $k . ' =& ' . '$arr[\'' . $k . '\'];'); $variablex = 9; print_r($variablex); print_r($arr['variablex']); This prints out 65758899. What this means is that the first assignment to the newly inserted symbol did not affect the array. It seems to be equivalent to the second snippet ($$k =& $v). Only do the third and the fourth snippets actually create references to the original content.

« previous php.notes (#22156) next »