Extracting variable values from nested arrays

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
tasha
Forum Newbie
Posts: 2
Joined: Mon Oct 25, 2004 5:51 am
Location: Brighton, UK

Extracting variable values from nested arrays

Post by tasha »

I need to extract the values from a nested array so that I can send an email each staff member that has a -ve number of points, currently only the array index number is send for $staffFK and nothing is sent for $total, I have tried several things none of which work, can anyone help?

//declare array existing negative points
$existingNegativePoints = array();
// check if they're new
foreach ($negList AS $staffFK => $total){
if ($existingNegativePoints[$staffFK] == ""){
array_push($existingNegativePoints, array($staffFK, $total));
mail($supportMail, "DTH - just found member with NEGATIVE POINTS!!", "StaffFK = " .$staffFK.", Points = ".$total);

}
}

Thank you
Tasha
ibizconsultants
Forum Commoner
Posts: 35
Joined: Tue Sep 07, 2004 12:07 pm

Post by ibizconsultants »

You could try using

if (isset($existingNegativePoints[$staffFK]) == false){
tasha
Forum Newbie
Posts: 2
Joined: Mon Oct 25, 2004 5:51 am
Location: Brighton, UK

Post by tasha »

I have realised that $total is an array itself, so the elements I need to access are in fact $total[0] and $total[1].

Thanks for help

Natasha
Post Reply