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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T08:05:18+00:00 2026-06-08T08:05:18+00:00

I am trying to reference something inside an array i get from a function.

  • 0

I am trying to reference something inside an array i get from a function.

Lets say I have a collection named $myArrays and when i call $myArrays->first(); I will get an array.

Now when I try to get the first element in my array with $myArrays->first()[0] this doesn’t work. Why is that so and is there a way to use it in a similar way?

Regards, Senad

  • 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-08T08:05:19+00:00Added an answer on June 8, 2026 at 8:05 am

    Because you are not using PHP 5.4:

    Function array dereferencing has been added, e.g. foo()[0]

    You need a temporary variable:

    $first = $myArrays->first();
    $first[0]
    

    And no, you cannot “trick” PHP this way either:

    ($myArray->first())[0]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an array of objects and I am trying to reference the name
This is the code from the class within which I am trying to reference
I am trying to set a new variable to reference a variable inside a
im trying to access my decorators arguments inside the wrapper function with no luck.
So, I'm trying to migrate a database from Textpattern CMS to something more generic.
I'm trying to pass a member function as an argument. Basically I have a
I have created simple .NET Web Service (ASMX) that I call from my .NET
I am trying to pass an array of Student into the function processStudent(string myFilename,
I have nested a function definition bar() inside another function foo() . Now I
I am trying to reference the jQuery library in my master page like so:

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.