Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6088557
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:59:54+00:00 2026-05-23T11:59:54+00:00

Ok, so I have a class and I would like to be able to

  • 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 =)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T11:59:55+00:00Added an answer on May 23, 2026 at 11:59 am

    to close this one up, the function should look like this ($i was in the wrong loop):

    public function getArtistTracks(){
        if( $tracks = getTracks() ){
            $i = 0;
            foreach ( $tracks['results'] as $track ){
                // $artistName is an array of strings (defined as public)
                $name[$this->artistName][$i] = $track['name'];
                $i++;               
            }
        }
    
        return $name;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a class in my asp.net proj, I would like to get access
I have an abstract class which I would like to be able to expose
I have a class that I would like to use in a scala.collection.mutable.PriorityQueue, but
I have an abstract class and I would like to use it quickly by
I have a static class that I would like to raise an event as
I have a class in silverlight that I would like to store to disk.
For a given class I would like to have tracing functionality i.e. I would
I have a class that is marked with DataContract attributes and I would like
I have a class MyClass, and I would like to override the method ToString()
I have a class that implements multiple interfaces. I would like to register these

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.