phpretard Posted April 19, 2008 Share Posted April 19, 2008 How do I unset just one part of the array? unset($_SESSION[$file]['P1040050.jpg']); <--doesn't work $_SESSION:Array ( [P1040050.jpg] => Array ( [picture] => ALBUMS/Holmes_Adams/P1040050.jpg [file] => P1040050.jpg [s46] => 4 x 6 [QU46] => 10 [s57] => 5 x 7 [QU57] => 20 [s810] => 8 x 10 [QU810] => 30 [order_photo] => Order This Photo ) [P1040052.jpg] => Array ( [picture] => ALBUMS/Holmes_Adams/P1040052.jpg [file] => P1040052.jpg [s46] => 4 x 6 [QU46] => 30 [s57] => 5 x 7 [QU57] => 20 [s810] => 8 x 10 [QU810] => 10 [order_photo] => Order This Photo ) ) Quote Link to comment https://forums.phpfreaks.com/topic/101820-unset-session/ Share on other sites More sharing options...
awpti Posted April 19, 2008 Share Posted April 19, 2008 unset($_SESSION[$file]['file']); Assuming $file is p1040050.jpg or whatever. Quote Link to comment https://forums.phpfreaks.com/topic/101820-unset-session/#findComment-521039 Share on other sites More sharing options...
phpretard Posted April 19, 2008 Author Share Posted April 19, 2008 <?php if ($action=='delete'){ $file="P1040050.jpg"; unset($_SESSION[$file]['file']); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/101820-unset-session/#findComment-521040 Share on other sites More sharing options...
wildteen88 Posted April 19, 2008 Share Posted April 19, 2008 That revised code should work, however it'll only remove the 'file' key from the P1040050.jpg array. Quote Link to comment https://forums.phpfreaks.com/topic/101820-unset-session/#findComment-521165 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.