I have different multidimensional arrays with different keys and values:
$array_1 = array('cars' => array('audi' => array('a3' => array('one', 'two', 'three'), 'a5' => array('five', 'six', 'seven')), 'mercedes' => array('type_1' => array('submodel' => array('whatever'))), 'other_cat' => array('different_things')));
then I would like to unset a specific key, for example:
unset($array_1['cars']['audi']['a5']);
Now I like to "split it up", to have the key variable.
$to_unset = ['cars']['audi']['a5'];
How can I unset that specific (variable!) key?
Aäron
to have the key variable?$to_unset = ['cars']['audi']['a5'];is not quite what you want. It is valid PHP code but it evaluates toNULL(and triggers a notice about the'audi'index not existing in the['cars']array). You should start by designing a way to define the list of keys you need to reach the item to unset.