title: access and remove element from $data array codeigniter
body: <p>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: </p>
  
  <pre><code>    foreach($data['arr1'] as $key =&gt; $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'] -&gt; 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
          }
  
      }
  </code></pre>
  
  <p>How can I access the element for checks? I think it is a combination of <code>data['arr1']</code> and <code>$key</code> but i cannot find a correct combination. Also when I do <code>print_r($data['arr1'])</code> it prints the whole array correctly. as:</p>
  
  <pre><code>Array ( [0] =&gt; stdClass Object ( [Id] =&gt; 107 [assessmentTime] =&gt; 0000-00-00 00:00:00  [Gender] =&gt; 1 [DOB] =&gt; 2009-05-06 12:00:00 [Village] =&gt; Bhains [Tehsil] =&gt; 1 [UnionCouncil] =&gt; 2 [Snap] =&gt; 582864.jpg  [WhyWeDisable] =&gt; [HasDeleted] =&gt; 0 [CallerID] =&gt; 0 [vTime] =&gt; 0000-00-00 00:00:00 [CaseId] =&gt; 98 ) [1] =&gt; stdClass Object ( [Id] =&gt; 57 [FirstName] =&gt; ..............
  </code></pre>
  
  <p>Any help would be much appreciated. </p>