-1

This is my 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 to use a few of the values such as con_firstname, con_lastname etc. How do i access them? Im trying to use it like so:

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

But i'm getting nothing back...

Any help appreciated cheers

Planty
  • 85
  • 1
  • 12

1 Answers1

1

That's an array containing an object. So you need to access the object using array syntax and then access the value using object syntax. You're also missing your echo statement. (And you need single quotes around array keys if this were actually an array).

echo $query[0]->con_firstname;
John Conde
  • 217,595
  • 99
  • 455
  • 496