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 Link to comment https://forums.phpfreaks.com/topic/141946-remove-dimension-from-ana-rray/ 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); Link to comment https://forums.phpfreaks.com/topic/141946-remove-dimension-from-ana-rray/#findComment-743257 Share on other sites More sharing options...
ILMV Posted January 22, 2009 Author Share Posted January 22, 2009 Many thanks dvd420! It worked perfectly Link to comment https://forums.phpfreaks.com/topic/141946-remove-dimension-from-ana-rray/#findComment-743280 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.