ILMV Posted January 22, 2009 Share Posted January 22, 2009 Hello all, I have an array that looks like this... array { 1 => audi 2 => ferrari 3 => fiat } Now I want to keep the ID, but I want to remove the value. i am currently doing this by using a foreach and manually reconstructing the array, is there a php function that allows me to get this result instead? Many Thanks ILMV Quote Link to comment Share on other sites More sharing options...
dvd420 Posted January 22, 2009 Share Posted January 22, 2009 use following, if you want to unset the values: $array = array(1 => "Audi", 2 => "Ferrari", 3 => "Fiat"); $keys = array_keys($array); array_fill_keys($keys, NULL); Quote Link to comment Share on other sites More sharing options...
ILMV Posted January 22, 2009 Author Share Posted January 22, 2009 Many thanks dvd420! It worked perfectly 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.