SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Dec 2006
    Posts
    88
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Can't echo array

    I don't know why I can't print out this array.

    I tried $query->id and I get nothing, I also tried $query[id] with no avail.

    print_r($query); is:

    Code PHP:
    Array
    (
        [0] => stdClass Object
            (
                [id] => 224
                [name] => Noel Brown
                [agent] => 5
                [address] => Via del ponte 4
                [city] => Miami
                [state] => Florida
                [country] => USA
                [postcode] => 
                [hits] => 373
                [report] => 1
            )
     
    )

    Any idea?

    Thanks.

  2. #2
    SitePoint Enthusiast
    Join Date
    Dec 2006
    Posts
    88
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by drag View Post
    I don't know why I can't print out this array.

    I tried $query->id and I get nothing, I also tried $query[id] with no avail.

    print_r($query); is:

    Code PHP:
    Array
    (
        [0] => stdClass Object
            (
                [id] => 224
                [name] => Noel Brown
                [agent] => 5
                [address] => Via del ponte 4
                [city] => Miami
                [state] => Florida
                [country] => USA
                [postcode] => 
                [hits] => 373
                [report] => 1
            )
     
    )

    Any idea?

    Thanks.
    Ok, sorted

    $query[0]->id;

    Thanks

  3. #3
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2008
    Posts
    5,757
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    $query[0]->id

    I'll guess this is being fetched from a database. You might prefer to specify an associative array instead of an object.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •