I have a associative array $data['arr1'] which is populated by a query. I need to iterate through the array , check each record for a specific value, and if the record is present , remove that record from the array. Here is my code:
foreach($data['arr1'] as $key => $row) {
// code for checking the value in a record. Cannot access the element here. I have
tried to print with these statements
echo $data['arr1'] -> Firstname;
echo $data['arr1'] [0];
echo $data['arr1'][$key];
echo [$key]; // gives me the values of index 0,1,2,3
if(//check is true)
{
unset($data['arr1'][$key]); //works fine, removes elements as needed
}
}
How can I access the element for checks? I think it is a combination of data['arr1'] and $key but i cannot find a correct combination. Also when I do print_r($data['arr1']) it prints the whole array correctly. as:
Array ( [0] => stdClass Object ( [Id] => 107 [assessmentTime] => 0000-00-00 00:00:00 [Gender] => 1 [DOB] => 2009-05-06 12:00:00 [Village] => Bhains [Tehsil] => 1 [UnionCouncil] => 2 [Snap] => 582864.jpg [WhyWeDisable] => [HasDeleted] => 0 [CallerID] => 0 [vTime] => 0000-00-00 00:00:00 [CaseId] => 98 ) [1] => stdClass Object ( [Id] => 57 [FirstName] => ..............
Any help would be much appreciated.