php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #34526 array-related operation to "reduce" contained items
Submitted: 2005-09-16 14:01 UTC Modified: 2013-03-15 14:53 UTC
From: soletan at toxa dot de Assigned:
Status: Duplicate Package: *General Issues
PHP Version: 5.0.5 OS: Linux
Private report: No CVE-ID: None
 [2005-09-16 14:01 UTC] soletan at toxa dot de
Description:
------------
Is it possible to have an array_xxxx-method to perform the transformation on arrays as given below. Since I am working with DBs and wrapping records of tables using classes I often
get the case to receive an array as given below and require
to pass the list of IDs, only.

For sure I can do the transformation all by myself in PHP using foreach. But since my software is getting more and more complex I appreciate any chance to increase my scripts' performance by having such trivial tasks being done in one step.


Reproduce code:
---------------
before:
array(
    array( 'id' => 1, 'foo' => 'bar' ),
    array( 'id' => 2, 'foo' => 'bar' ),
    array( 'id' => 3, 'foo' => 'bar' ),
    array( 'id' => 4, 'foo' => 'bar' ),
    array( 'id' => 5, 'foo' => 'bar' )
);

action:
$out = array_xxxxx( $in, 'id' );

result:
array( 1, 2, 3, 4, 5 );



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-03-15 14:53 UTC] nikic@php.net
-Status: Open +Status: Duplicate -Package: Feature/Change Request +Package: *General Issues
 [2013-03-15 14:53 UTC] nikic@php.net
Duplicate of https://bugs.php.net/bug.php?id=26338.
 
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Sun Nov 19 01:31:42 2017 UTC