Just trying to return an array in a function. Not having the best of luck...
( flag_friend_get_friends() is a function that returns a list of objects containing arrays )
So without a function, this works:
<?php
$users_friends = flag_friend_get_friends($user->uid);
foreach ($users_friends as $id => $value) {
$users_friends_ids[] = $id;
}
$test = $users_friends_ids;
print $test[0];
?>
If I try and wrap it an a function, it doesn't work (nothing is printed)...:
<?php
function myfunc () {
$users_friends = flag_friend_get_friends($user->uid);
foreach ($users_friends as $id => $value) {
$users_friends_ids[] = $id;
}
return $users_friends;
}
$test = myfunc();
print $test[0];
?>
What's the 'deliberate' mistake? :(
Updated code:
<?php
function myfunc () {
$users_friends = flag_friend_get_friends($user->uid);
foreach ($users_friends as $id => $value) {
$users_friends_ids[] = $id;
}
return $users_friends;
}
$test = myfunc($user);
print $test[0];
?>