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 8243831
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T21:39:02+00:00 2026-06-07T21:39:02+00:00

I am calling a function that returns an array, but I’m running into this

  • 0

I am calling a function that returns an array, but I’m running into this error: Can’t use function return value in write context

Lots of people get this error, but I can’t see what I’ve done wrong.

This is the function:

function select_image_styles_from_category($category)
{
$image_details();
switch($category)
{
    case 'twine':
            $image_details[0] = get_bloginfo('template_directory') . '/images/titles/blog-twine.png';
            $image_details[1] = 'on-top';
            break;
    case 'scrapbook':
            $image_details[0] = get_bloginfo('template_directory') . '/images/blog/papers.png';
            $image_details[1] = 'on-top';
            break;
    default:
            $image_details[0] = 'stuff';
            $image_details[1] = 'things';
}

return $image_details;

}

I then call this function from another function and this is the line it errors (there is more in this function, but it’s just superfluous to the rest of the question):

function add_img_styles_to_special_categories($the_content_string, $category)
{
        //erroring line
    $image_details() = select_image_styles_from_category($category);
}

Am I missing a cast? Do I need to explicitly construct an array? Have I cocked up the case statement? I really can’t see what I’m missing. Any of you gorgeous lovelies have any pointers?

  • 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-06-07T21:39:04+00:00Added an answer on June 7, 2026 at 9:39 pm

    You have written code that looks like it’s calling a function, when you just want to assign to a variable.

    This

    $image_details();
    

    means “take the value of $image_details, interpret it as the name of a function and call that function”.

    So when you (mistakenly obviously) put the extra parens and wrote

    $image_details() = select_image_styles_from_category($category);
    

    the compiler read this as “take the value of $image_details, interpret it as the name of a function, call that function and assign the result of select_image_styles_from_category() to it“. But you cannot assign anything to the result of a function (you can only store it somewhere), hence the error.

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

Sidebar

Related Questions

I'm trying to return a value from (transport) to the calling function, but can't
It is my understanding that you can return an array from a function in
I have a function that is calling wget via subprocess.Popen. The purpose of this
When calling functions that always throw from a function returning a value, the compiler
This is the function that im calling. function GetSubmissions($coach){ $result = mysql_query(SELECT * FROM
I have a function in PostgreSQL (PLPGSQL) that returns an array containing two elements.
I'm using MATLAB and am calling a function that returns properties of the screen.
I have a function that is recursively calling itself, and i want to detect
I am calling a function and passing 3 parameters to that. I am taking
I have the view function in django that written like a dispatcher calling other

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.