Northern Flame Posted March 25, 2008 Share Posted March 25, 2008 is there a function that deletes a value from an array? so that if i had <?php $array = array('value', 'val', 'random', 'string'); $delete = 'val'; ?> how do i delete val, which is stored in $delete, from the array? Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted March 25, 2008 Share Posted March 25, 2008 Check this site out: http://tech.petegraham.co.uk/2007/03/22/php-remove-values-from-array/ Quote Link to comment Share on other sites More sharing options...
Northern Flame Posted March 25, 2008 Author Share Posted March 25, 2008 thanks thats exactly what i was looking for! Quote Link to comment Share on other sites More sharing options...
Barand Posted March 25, 2008 Share Posted March 25, 2008 or, if you know the key of the element to remove, use unset() <?php $val = 2; $a = array(1,2,3,4,5); $key = array_search($val,$a); unset ($a[$key]); echo '<pre>', print_r($a, true), '</pre>'; ?> 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.