hasanatkazmi Posted August 9, 2007 Share Posted August 9, 2007 is there some handy and short method to delete an element from an array and than shifting the rest of elements one place ahead e.g array(1,2,3,4,5,6) becomes array(1,2,4,5,6) Quote Link to comment https://forums.phpfreaks.com/topic/64166-solved-deleting-an-element-from-an-array/ Share on other sites More sharing options...
teng84 Posted August 9, 2007 Share Posted August 9, 2007 look for array pop and array push those are the answer Quote Link to comment https://forums.phpfreaks.com/topic/64166-solved-deleting-an-element-from-an-array/#findComment-319778 Share on other sites More sharing options...
hasanatkazmi Posted August 9, 2007 Author Share Posted August 9, 2007 but pop and push remove and add from end of array and at its begining Quote Link to comment https://forums.phpfreaks.com/topic/64166-solved-deleting-an-element-from-an-array/#findComment-319782 Share on other sites More sharing options...
Fadion Posted August 9, 2007 Share Posted August 9, 2007 array_pop and array_shift will remove the first and last array element. Instead u can use just unset($arr[key]) where key is the numeric or string value that points to that array. Quote Link to comment https://forums.phpfreaks.com/topic/64166-solved-deleting-an-element-from-an-array/#findComment-319785 Share on other sites More sharing options...
teng84 Posted August 9, 2007 Share Posted August 9, 2007 ok this will do sorry i dont read your q carefully $input = array("a", "b", "c", "d", "e"); unset($input[2]); print_r($input); try Quote Link to comment https://forums.phpfreaks.com/topic/64166-solved-deleting-an-element-from-an-array/#findComment-319791 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.