note 129825 added to function.unset

From: Date: Mon, 28 Oct 2024 19:51:51 +0000
Subject: note 129825 added to function.unset
Groups: php.notes 
Request: Send a blank email to php-notes+get-221618@lists.php.net to get a copy of this message
I couldn't find this clarification elsewhere in the notes, but it seems important, so at the risk of duplication.... While a global variable, like a whole array, is not unset from within a function, an element of the array, is unset. So <? function myfunction(){ Global $test; unset($test[1]); print_r($test); unset($test) } $test = array(1,2,3); myfunction(); print_r($test); ?> Produces: Array ( [0] => 1 [2] => 3 ) # from inside myfunction Array ( [0] => 1 [2] => 3 ) # on return from myfunction ---- Server IP: 45.112.84.4 Probable Submitter: 45.112.84.18 (proxied: 24.87.154.112) ---- Manual Page -- https://php.net/manual/en/function.unset.php Edit -- https://main.php.net/note/edit/129825 Del: integrated -- https://main.php.net/note/delete/129825/integrated Del: useless -- https://main.php.net/note/delete/129825/useless Del: bad code -- https://main.php.net/note/delete/129825/bad+code Del: spam -- https://main.php.net/note/delete/129825/spam Del: non-english -- https://main.php.net/note/delete/129825/non-english Del: in docs -- https://main.php.net/note/delete/129825/in+docs Del: other reasons-- https://main.php.net/note/delete/129825 Reject -- https://main.php.net/note/reject/129825 Search -- https://main.php.net/manage/user-notes.php

« previous php.notes (#221618) next »