php - access and remove element from $data array codeigniter -


i have associative array $data['arr1'] populated query. need iterate through array , check each record specific value, , if record present , remove record array. here code:

    foreach($data['arr1'] $key => $row) {          // code checking value in record. cannot access element here. have             tried print these statements         echo $data['arr1'] -> firstname;         echo $data['arr1'] [0];         echo $data['arr1'][$key];         echo [$key]; // gives me values of index 0,1,2,3          if(//check true)         {             unset($data['arr1'][$key]);  //works fine, removes elements needed         }      } 

how can access element checks? think combination of data['arr1'] , $key cannot find correct combination. when print_r($data['arr1']) prints 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 appreciated.

try

foreach( $data $obj ){   echo $obj->id;   ..etc. } 

you confusing array of objects multi-dimensional array.

or can output them manually

echo $data[0]->id; 

if need @ first one.

anyway give away here bit, when print whole array out.

 array ( [0] => stdclass object ( 

see says object. arrays access [ key ] objects access $obj->property.


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -