Skip to content

Instantly share code, notes, and snippets.

@smokills
Last active March 29, 2017 08:33
Show Gist options
  • Save smokills/c67619ac153dc42cc9ec1f3f5d5b54a7 to your computer and use it in GitHub Desktop.
Save smokills/c67619ac153dc42cc9ec1f3f5d5b54a7 to your computer and use it in GitHub Desktop.
Return an array that contains the value of the given column name
<?php
function extract_field($object, $field) {
return array_column(
array_map(function($e) {
return (array)$e;
}, (array)$object),
$field);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment