Categories > TinyButStrong general >

object array var

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Jared
Date: 2007-06-15
Time: 04:33

object array var

What would the syntax be to access a value of an array that belong to an object?
By: TomH
Date: 2007-06-15
Time: 11:06

Re: object array var

If you had a data object like...
Array
(
    [rss attr] => Array
        (
            [version] => 2.0
        )

    [rss] => Array
        (
            [channel attr] => Array
                (
                    [version] => 2.0
                )

            [channel] => Array
                (
                    [title] => Daily Star Front Page
                    [link] => http://www.azstarnet.com/sn/dailystar/
                    [description] => Daily Star Front Page headlines from the Arizona Daily Star
                    [language] => en-us
                    [pubDate] => 2007-06-15
                    [ttl] => 60
                    [item] => Array
                        (
                            [0] => Array
                                (
                                    [title] => Guardsman 'died as he wanted — with honor'
                                    [link] => http://www.azstarnet.com/sn/dailystar/187672.php
                                    [description] => Why would a soldier who had just returned from war turn right around and offer to go again?
                                    [category] => 0x07000000
                                    [enclosure attr] => Array
                                        (
                                            [url] => http://www.azstarnet.com/ss/2007/06/15/187672-4.jpg
                                            [type] => image/jpeg
                                        )

You would use a block syntax like
[blk1.rss.channel.title;.]

There are several examples (with source code) of handling data objects at http://tomhenry.us/tbs3/
-- hope that helps,
TomH
By: Jared
Date: 2007-06-15
Time: 20:58

Re: object array var

Thanks, that helped.

I have an object like this:
class X {
  var $y;

  function X() {
    var $y = array();
  }

  function Z() {
    $this->y['a']['1'] = "123";
    $this->y['b']['1'] = "xyz";
  }

}

So in order to hit my objects member array, I used this syntax:

$test =& new X;

[var.test.y.a.1]
[var.test.y.b.1]

- Jared