Created
May 26, 2016 09:11
-
-
Save smottt/6d5ca0c0865d11ba88b145e2865a6fc0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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