Forum Moderators: coopster
Array ( [Formula 2 Flake] => Array ( [0] => 34g ) [Formula 2 Medium Pellet] => Array ( [0] => 400g ) )
second array is called $list and come from db extraction
Array ( [Formula 2 Flake] => Array ( [0] => 34g [1] => 70g ) [Formula 2 Medium Pellet] => Array ( [0] => 100g [1] => 200g [2] => 400g ) )
I want to delete the values 34g and 400g from $list
foreach($list as $k => $v)
{
foreach($v as $v1 => $v2)
{
if(in_array(array($v2),$delete))
{
echo"$v2 is in delete<br />";
unset($list[$v2]);
}
}
}
The problem here ( I think) is that unset is addressing a flat array, after many hours searching ( php.net etc) I cannot find, or work out what the proper syntax should be.
Any help greatly appreciated
Many Thanks
SteveD
foreach($delete as $name =>$a)
{
foreach($a as $k => $weight)
{
if(isset($list,$weight))
{
echo "itme = $name :: weight = $weight<br />";
unset($list[$name][$weight]);
}
}
}
Cheers
Steve
array_search(), which will give you the key, which you can then delete by using unset($array[$key]), or if you're not in the global namespace, unset($GLOBALS[$array][$key]).
Thank you both for your input
Cheers
Steve