Zaid Posted April 8, 2007 Share Posted April 8, 2007 btw, im trying to use unset() from inside a method class cookie(){ public $cookie_array_full; function blahblah($key){ unset($GLOBALS['cookie_array_full[0][$key]']); } } any idea why it doesn't work? Link to comment https://forums.phpfreaks.com/topic/46164-solved-can-you-use-unset-on-multidimentional-arrays-it-doesnt-seem-to-work/ Share on other sites More sharing options...
wildteen88 Posted April 8, 2007 Share Posted April 8, 2007 That is invalid call to an array element: $GLOBALS['cookie_array_full[0][$key]'] It should like this: $GLOBALS['cookie_array_full'][0][$key] Link to comment https://forums.phpfreaks.com/topic/46164-solved-can-you-use-unset-on-multidimentional-arrays-it-doesnt-seem-to-work/#findComment-224384 Share on other sites More sharing options...
Zaid Posted April 8, 2007 Author Share Posted April 8, 2007 That is invalid call to an array element: $GLOBALS['cookie_array_full[0][$key]'] It should like this: $GLOBALS['cookie_array_full'][0][$key] still doesn't work i got it to work but using a different syntax: unset($this->cookie_array_full[0][$key]); Link to comment https://forums.phpfreaks.com/topic/46164-solved-can-you-use-unset-on-multidimentional-arrays-it-doesnt-seem-to-work/#findComment-224386 Share on other sites More sharing options...
wildteen88 Posted April 8, 2007 Share Posted April 8, 2007 What is the format of the $GLOBALS['cookie_array_full'] array? To see the format of $GLOBALS['cookie_array_full'] array use print_r, example: echo '<pre>' . print_r($GLOBALS['cookie_array_full'], true) . '</pre>'; Link to comment https://forums.phpfreaks.com/topic/46164-solved-can-you-use-unset-on-multidimentional-arrays-it-doesnt-seem-to-work/#findComment-224389 Share on other sites More sharing options...
Zaid Posted April 8, 2007 Author Share Posted April 8, 2007 What is the format of the $GLOBALS['cookie_array_full'] array? To see the format of $GLOBALS['cookie_array_full'] array use print_r, example: echo '<pre>' . print_r($GLOBALS['cookie_array_full'], true) . '</pre>'; Array ( [0] => Array ( [0] => 3 [1] => 65 ) [1] => Array ( ) ) i've read that unset will work inside a function, but will only change it locally, even when the array is a global array and therefore i should use $GLOBALS, but i guess it doesn't work Link to comment https://forums.phpfreaks.com/topic/46164-solved-can-you-use-unset-on-multidimentional-arrays-it-doesnt-seem-to-work/#findComment-224392 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.