php - Get specific element from array -


this question has answer here:

this array called $query

array (     [0] => stdclass object         (         [con_id] => 6         [con_firstname] => joe         [con_lastname] => bloggs         [con_username] => bloggs@mail.com         [con_password] => password         [con_job_category_id] => 0         [con_updated_at] => 0000-00-00 00:00:00         [con_created_at] => 0000-00-00 00:00:00     )  ) 

i want use few of values such con_firstname, con_lastname etc. how access them? im trying use so:

value="<?php $query[con_firstname]; ?>"  

but i'm getting nothing back...

any appreciated cheers

that's array containing object. need access object using array syntax , access value using object syntax. you're missing echo statement. (and need single quotes around array keys if array).

echo $query[0]->con_firstname; 

Comments