View Full Version : Removing a value from an associative array
NancyJ
11-23-2007, 11:55 PM
Is there any way I can remove a key/value pair from an associative array, given the key?
CFMaBiSmAd
11-24-2007, 12:02 AM
unset() -
$arr['keep_this_1'] = 'I want 1';
$arr['remove_this'] = 'this will be gone';
$arr['keep_this_2'] = 'I want 2';
echo "<pre>";
print_r($arr);
echo "</pre>";
echo "<br />";
$key = 'remove_this';
unset($arr[$key]);
echo "<pre>";
print_r($arr);
echo "</pre>";
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.