I think you may need to pass the index to the function and have the function return the array value for that index
$joe = 'b';
$my_array = array('a','b');
if($joe =& ret_index($my_array,2))
very untested though.
I don't think PHP naturally has returned values from functions, you'd have to code your own workaround.