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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T04:38:36+00:00 2026-05-18T04:38:36+00:00

I’ve just been running some simple debug tests against arrays, and noticed that when

  • 0

I’ve just been running some simple debug tests against arrays, and noticed that when I do a var_dump() of an array, the output is flagging any element in the array that is referenced by another variable. As a simple experiment, I ran the following code:

$array = range(1,4);

var_dump($array);
echo '<br />';

foreach($array as &$value) {
}

var_dump($array);
echo '<br />';

$value2 = &$array[1];

var_dump($array);
echo '<br />';

which gives the following output:

array(4) { [0]=> int(1) [1]=> int(2) [2]=> int(3) [3]=> int(4) } 
array(4) { [0]=> int(1) [1]=> int(2) [2]=> int(3) [3]=> ∫(4) } 
array(4) { [0]=> int(1) [1]=> ∫(2) [2]=> int(3) [3]=> ∫(4) } 

Note the ∫ symbol alongside element 3 and subsequently element 1. Note also that those entries don’t show the entry’s datatype.

Following some experimentation, I don’t see this if I var_dump a scalar type, or with objects or resources. If the array contains string data, the symbol is a & (and it does still show the datatype), likewise with float, boolean and object entries.

This is running against PHP 5.2.8

First question: When did this behaviour start, or is it something that I simply haven’t noticed before now?

Second question: If referenced elements can be flagged in this way by var_dump(), is there any function in core PHP that will allow me to identify if an array element is referenced by another variable; or that will return the refcount or ref flag from a _zval_struct?

  • 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-18T04:38:36+00:00Added an answer on May 18, 2026 at 4:38 am

    Not sure if this answers your question, but you can use

    debug_zval_dump($array);
    

    to get the refcount:

    array(4) refcount(2){ 
        [0]=> long(1) refcount(1) 
        [1]=> &long(2) refcount(2) 
        [2]=> long(3) refcount(1) 
        [3]=> &long(4) refcount(2) 
    } 
    

    Also see this Article by Derick Rethans (PHP Core Dev) about Refcounting.

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

Sidebar

Related Questions

No related questions found

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.