PHPackages                             dcelasun/extract\_property - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. dcelasun/extract\_property

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

dcelasun/extract\_property
==========================

Extracts a given property from an array of objects

1.0.1(12y ago)225MITPHP

Since Jul 11Pushed 12y ago1 watchersCompare

[ Source](https://github.com/dcelasun/extract_property)[ Packagist](https://packagist.org/packages/dcelasun/extract_property)[ Docs](https://github.com/dcelasun/extract_property)[ RSS](/packages/dcelasun-extract-property/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependenciesVersions (3)Used By (0)

extract\_property() for PHP
===========================

[](#extract_property-for-php)

[![Build Status](https://camo.githubusercontent.com/2eafaaaa964309e625f70387d02cb0b8a67f9b8e93cb0838f823073847544ce9/68747470733a2f2f7472617669732d63692e6f72672f6463656c6173756e2f657874726163745f70726f70657274792e706e67)](https://travis-ci.org/dcelasun/extract_property)

This simple library provides an easy way to extract a given property from an array of objects.

Usage
-----

[](#usage)

```
array extract_property( array $objects, mixed $key [, mixed $index] )

```

Given an array of objects, `extract_property()` returns the values from a single property of each object, identified by `$key`. Optionally, you may provide an `$index` to index the values in the returned array by the values from the `$index` property of each object in the input array.

For example, using the following `$users` array, we tell `extract_property()` to return an array of just the names, indexed by their record IDs.

```
