I need to be able to remove a custom key from an array inserted into a WordPress options table, here is the array i get in return using print_r:
Array (
[customkeyone] => Array (
[itemname] => 'name'
[sortorder] => 1
[date] => 1393042529
[target] => 1
)
[customkeytwo] => Array (
[itemname] => 'nametwo'
[sortorder] => 1
[date] => 1393042525
[target] => 1
)
[customkeythree] => Array (
[itemname] => 'namethree'
[sortorder] => 1
[date] => 1393042522
[target] => 1
)
)
I tried different methods and have come close but not able to actually remove/unset the entire custom key itself. Lets say I want to unset "customkeytwo", I would need a way to pass this custom id and remove it:
Handler example:
if (isset($_GET['delete'])) {
//ID in this case is "customkeytwo"
if ($_REQUEST['id'] != ''){
$id = $_REQUEST['id'];
$myoptions = get_option('myoptions');
//some method to unset the custom key with $id
//update with new results
update_option('myoptions', $myoptions);
And this is how I want the result to be after I remove it:
Array (
[customkeyone] => Array (
[itemname] => 'name'
[sortorder] => 1
[date] => 1393042529
[target] => 1
)
[customkeythree] => Array (
[itemname] => 'namethree'
[sortorder] => 1
[date] => 1393042522
[target] => 1
)
)