SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Enthusiast icrafter's Avatar
    Join Date
    Nov 2001
    Location
    Denver, CO
    Posts
    30
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Large Array Values

    I get a array like this from a xml/php script.

    PHP Code:
    Array ( [0] => index Object ( [company_name] => DOW JONES INDUSTRIALS INDEX [ticker] => INDU [exchange] => Not Available [last] => 8516.43 [change] => 25.07 (0.30%) [time_last] => 05/2116:59 [day_open] => 8485.62 [day_high] => 8523.16 [day_low] => 8431.21 [volume] => ) [1] => index Object ( [company_name] => NASDAQ COMPOSITE INDX [ticker] => COMPX [exchange] => Not Available [last] => 1489.87 [change] => -1.22 (-0.08%) [time_last] => 05/2116:59 [day_open] => 1488.27 [day_high] => 1490.82 [day_low] => 1478.15 [volume] => ) ) 

    I can't figure out how to pull out certain value currently I am trying this and it give me a blank line nothing, no errors

    PHP Code:
    echo "{$db[1]['company_name']}!"
    $db is the original array variable
    Paul K. Zorn - pzorn@interlacedmedia.com
    All help is always good and I will always try to help back.

    http://www.interlacedmedia.com/ - Full Service Graphic Design, Multimedia, Photography, Video and Web Shop.

  2. #2
    Sidewalking anode's Avatar
    Join Date
    Mar 2001
    Location
    Philadelphia, US
    Posts
    2,205
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    $db[1] is an object, try accessing it as $db[1]->company_name.
    TuitionFree a free library for the self-taught
    Anode Says... Blogging For Your Pleasure

  3. #3
    SitePoint Guru
    Join Date
    Aug 2001
    Location
    Amsterdam
    Posts
    788
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Edit:

    the better solution in the post above


    and also try

    print_r($db);

    this will show the build for the array..
    Last edited by peanuts; May 22, 2003 at 02:37.
    the neigbours (free) WIFI makes it just a little more fun

  4. #4
    ********* Genius Mike's Avatar
    Join Date
    Apr 2001
    Location
    Canada
    Posts
    5,458
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think Anode's way should solve your problem.
    Mike
    It's not who I am underneath, but what I do that defines me.

  5. #5
    SitePoint Enthusiast icrafter's Avatar
    Join Date
    Nov 2001
    Location
    Denver, CO
    Posts
    30
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you very much the $db[1]->company_name worked perfectly.
    Paul K. Zorn - pzorn@interlacedmedia.com
    All help is always good and I will always try to help back.

    http://www.interlacedmedia.com/ - Full Service Graphic Design, Multimedia, Photography, Video and Web Shop.


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
  •