Skip to content

Instantly share code, notes, and snippets.

@smottt
Created May 26, 2016 09:11
Show Gist options
  • Save smottt/6d5ca0c0865d11ba88b145e2865a6fc0 to your computer and use it in GitHub Desktop.
Save smottt/6d5ca0c0865d11ba88b145e2865a6fc0 to your computer and use it in GitHub Desktop.
<?php
function getName(array $result)
{
// resets the array pointer
// possibly be bad
// but let's say it isn't in this case
$firstEntry = reset($result);
if (is_array($firstEntry) && isset($firstEntry['name'])) {
return $firstEntry['name'];
}
return 'No name';
}
echo getName($result);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment