Dale_G Posted November 20, 2008 Share Posted November 20, 2008 hey, i was wondering if its possible to delete an item from an array? $maybe = array( 'xx', 'xxx', 'x', 'abc', 'xxxxxx' ); How could I remove "abc" ($maybe[3]) from the array entirely so that the array would now look something like this: $maybe = array( 'xx', 'xxx', 'x', 'xxxxxx' ); Quote Link to comment Share on other sites More sharing options...
trq Posted November 20, 2008 Share Posted November 20, 2008 unset($maybe[3]) Quote Link to comment Share on other sites More sharing options...
flyhoney Posted November 20, 2008 Share Posted November 20, 2008 unset($maybe[3]); Quote Link to comment Share on other sites More sharing options...
Dale_G Posted November 21, 2008 Author Share Posted November 21, 2008 Oops, I meant like where everything shifts over afterwards, so its as if it was never there and $maybe[3] could still be called, it would just be "xxxxxx" now. Basically, delete one item from an array, and shift everything over so all the keys are preserved. Sorry! Quote Link to comment Share on other sites More sharing options...
Dale_G Posted November 21, 2008 Author Share Posted November 21, 2008 *double post* Quote Link to comment Share on other sites More sharing options...
trq Posted November 21, 2008 Share Posted November 21, 2008 array_splice($maybe,3,1) Quote Link to comment Share on other sites More sharing options...
Dale_G Posted November 21, 2008 Author Share Posted November 21, 2008 You got it! Quote Link to comment 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.