Commit 68d9210e authored by Taylor Otwell's avatar Taylor Otwell

Added array_pluck method.

parent e9bcbeac
......@@ -63,6 +63,8 @@
- Added `Input::replace` method.
- Added saving, saved, updating, creating, deleting, and deleted events to Eloquent.
- Added new `Sectionable` interface to allow cache drivers to simulate namespacing.
- Added support for `HAVING` SQL clauses.
- Added `array_pluck` helper, similar to pluck method in Underscore.js.
<a name="upgrade-3.2"></a>
## Upgrading From 3.1
......
......@@ -229,6 +229,22 @@ function array_divide($array)
return array(array_keys($array), array_values($array));
}
/**
* Pluck an array of values from an array.
*
* @param array $array
* @param string $key
* @return array
*/
function array_pluck($array, $key)
{
return array_map(function($v)
{
return is_object($v) ? $v->$key : $v[$key];
}, $array);
}
/**
* Determine if "Magic Quotes" are enabled on the server.
*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment