CardBoy Posted October 24, 2017 Share Posted October 24, 2017 Hi I have an array declared as static $array = array( 'a0' => array( 'b1' => array( 'c0' => 5, 'c1' => 'hi', ), 'b2' => array( 'd0' => 5, 'd1' => 'hi', ), ), 'a2' => 10, ); What I need to do is to loop over the array and extract a set of arrays such that these new arrays have an element removed, but leaving the original array in tact. So the first array in the set would remove 'a0' and looks like static $array = array( 'a2' => 10, ); The second would remove [a0][b1] and looks like static $array = array( 'a0' => array( 'b2' => array( 'd0' => 5, 'd1' => 'hi', ), ), 'a2' => 10, ); etc Please can anyone help? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/305437-array-manipulation/ Share on other sites More sharing options...
Barand Posted October 24, 2017 Share Posted October 24, 2017 unset $myarray['a0']; unset $myarray['a0']['b1']; Quote Link to comment https://forums.phpfreaks.com/topic/305437-array-manipulation/#findComment-1552984 Share on other sites More sharing options...
Sepodati Posted October 24, 2017 Share Posted October 24, 2017 This sounds like a classic "help me solve my solution" rather than "help me solve my problem"... Quote Link to comment https://forums.phpfreaks.com/topic/305437-array-manipulation/#findComment-1552995 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.