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

  • Home
  • SEARCH
  • 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 6570555
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T14:46:15+00:00 2026-05-25T14:46:15+00:00

I what to get a value returned from a object method and put it

  • 0

I what to get a value returned from a object method and put it into an array. The codes is as follows:

$additionalTestConfirmation = array();

$additionalTests = $this->getAdditionalTestsSelected();


foreach($additionalTests as $availableTest)
{
  $additionalTestConfirmation = $availableTest->getName();

}

$appointment = $this->getAppointment();

$tokens = array(
  '%DATE%' => $this->getAppointment()->getDate(),
  '%LOCATION%' => $this->getAppointment()->getLocation(),
  '%TIME%' => $this->getTime(),
  '%ROOM%' => $this->getRoom(),
  '%NAME%' => ($this->getUser() ? $this->getUser()->getFullName() : null),
  '%TZ%'   => $this->getAppointment()->getShowTimeZone() ? $this->getAppointment()->getTimeZone() : '',
  '%AdditionalTestsSelected%' => $additionalTestConfirmation,
);

For the codes above, I got a system error message: Notice: Array to string conversion in /Users/alexhu/NetBeansProjects/menagerie/svn/trunk/apps/frontend/modules/legacy/legacy_lib/lib/classes/AppointmentTime.php on line 379.
How do I avoid this and get the $availableTest->getName() returned value I want. thanks

  • 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-25T14:46:15+00:00Added an answer on May 25, 2026 at 2:46 pm

    When you assign elements to an array, you must either specify an index, or use empty square brackets ([]) to add an item:

    foreach($additionalTests as $availableTest) {
      $additionalTestConfirmation[] = $availableTest->getName();
      // or array_push($additionalTestConfirmation, $availableTest->getName()); 
      // see: http://us3.php.net/array_push
    }
    

    See the docs for more: http://php.net/manual/en/language.types.array.php

    EDIT

    Also, on this line:

    '%AdditionalTestsSelected%' => $additionalTestConfirmation,
    

    … you are passing an array into this index. If the code afterword expects this to be a string, that could cause the errors. *This is not causing the error – it is perfectly acceptable to put an array in another array. As I mentioned, though, it really depends on what the code that uses the $tokens array will do and expect. If it expects a plain string for the AdditionalTestsSelected index, you might need to do this:

    '%AdditionalTestsSelected%' => implode(',', $additionalTestConfirmation)
    

    … to make the value a comma-delimited list.

    Also note, at the end of that line you have an extra comma.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was wondering how to extract data from a returned object via jQuery's $.get()
I am getting some weird numbers returned from the characterAtIndex method for Object-C in
I face a problem when I try to get value from primary table in
I have a via with some jQuery function to get value from HTML element
For example i have this xml. I need to get value of parameter val
I need to get a value from a textbox inside a FooterTemplate in the
im trying to return a string value from a method inside my script tag
This is a slightly different question to this one ([ Accessing a method from
I've got an object returned from a field msg which is an object. I'm
I have an array declared inside a user defined method. I use this array

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.