tags:

views:

26

answers:

0

Ok, so I have a class and I would like to be able to get any trackName (two dimensional array) after initializing an object in another php script. This is a part of the class that is relevant:

class fetchData{
public $artistName;
public $trackName;

public function getArtistTracks(){
    $i = 0;

    if( $tracks = getTracks() ){
        foreach ( $tracks['results'] as $track ){
            // $artistName is an array of strings (defined as public)
            $name[$this->artistName][$i] = $track['name'];
            $i++;               
        }
    }

    return $name;
}

// later in the class one other function there is this
function initialize(){
    ...
    ...
    $this->trackName = $this->getArtistTracks();
}
}

Here is how I thought I could call artistName and trackName from another script:

$temp = new fetchData();
echo $temp->artistName[3]; // this works (returns 'some_artist_name' for example)
echo $temp->trackName[$temp->artistName[3]][1]; // this doesn't work
echo $temp->trackName['some_artist_name'][1]; // this also doesn't work

I tried a few other ways. For example instead of this:

$name[$this->artistName][$i] = $track['name'];

I would put this:

$this->name[$this->artistName][$i] = $track['name'];

without the return in getArtistTracks() and without the line in initialize() but that didn't work also. how can I get these trackNames from within another script?

thank you =)