I want to be able to access the array directly from the return value of the function.
e.g.
$arr = find_student();
echo $arr['name'];
// I want to be able to do
echo find_student()['name']
How can I accomplish the same ? Without another line of code ?
You can't. The PHP syntax parser is limited and does not allow it in current versions.
The PHP devs extended the parser for upcoming releases of PHP. Here's a link to a blog talking about it