PDA

View Full Version : Arrays and keys


filburt1
01-05-2003, 03:18 AM
How can I take an array and remove all elements of the array that have numeric keys?

Example: given an array $a['0'], $a['something'], $a['another1'], how can I remove $a['0']? I'm not talking about emptying the value but unset'ing that entire element.

Scott MacVicar
01-05-2003, 11:22 AM
couple of ways off the top of my head

foreach ($a as $key => $var)
{
if (is_numeric($key))
{
unset($a["$key"]);
}
}

filburt1
01-05-2003, 02:11 PM
Thanks :)