Skip to content
This repository has been archived by the owner on Jan 8, 2019. It is now read-only.

Return original index #3

Open
sagikazarmark opened this issue May 5, 2014 · 6 comments
Open

Return original index #3

sagikazarmark opened this issue May 5, 2014 · 6 comments

Comments

@sagikazarmark
Copy link

It would be great if the function could return the original index of the row.

Example:

$array = array(
    'key' => array(
        'element' => 'value'
    )
);

// Returns array('key' => 'value')
array_column($array, 'element', true);

I know it only mimics the core function, but still would be a great feature.

@ramsey
Copy link
Owner

ramsey commented May 8, 2014

Thanks for the recommendation. I don't disagree with this feature, but it was discussed and decided not to include it in core PHP. Since this library is intended to maintain parity with core, I won't be adding it here, unless it gets added to core.

See here for reference:

@ramsey ramsey closed this as completed May 8, 2014
@sagikazarmark
Copy link
Author

IMO the referenced discussion is mostly against the other two features. The first feature could still be merged.

Only thing I would modify: The third param should be true to use the original index, so you have the opportunity to get a reindexed array.

Do you see any chance of it?

@ramsey
Copy link
Owner

ramsey commented May 8, 2014

I'll reopen this and give it some thought. If I do it, I'll need to get it accepted into core first, and then add it here, but it will put users in an odd state, since the functionality won't exist in 5.5, while it exists in this library, which they can't use if they're using 5.5.

@ramsey ramsey reopened this May 8, 2014
@sagikazarmark
Copy link
Author

I think it makes sense to maintain a separate version for all PHP versions if the core changes. However it is also harder.

@ramsey
Copy link
Owner

ramsey commented Dec 5, 2014

Is this the functionality you're asking for?

https://bugs.php.net/bug.php?id=66435

@sagikazarmark
Copy link
Author

I am unable to fully understand that request. However, if I understand it well then it does not make sense.

What I would like is the following:

$arr = [
    'key' => [
        'foo' => 'bar',
    ],
];

// returns ['key' => 'bar']
array_column($arr, 'foo', true?);

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants