im trying to make facebook upload photo with random tag friend.
the program was run correctly but i got stack on the array
$args = array(
'message' => 'Test Tags Text',
"access_token" => $access_token,
"image" => $files,
'tags' => $id,
);
the $id is array friend list here the format
$friends = $facebook->api('/me/friends');
$frand = array_rand( $friends['data'], 20 );
foreach($frand as $fid){
$id[$fid]['tag_uid'] = $friends['data'][$fid]['id'];
$id[$fid]['x'] = 0;
$id[$fid]['y'] = 0;
}
Update 2:
Please read about arrays: PHP manual arrays. Every element in an array has a key even if you don’t specify it. You cannot have an element in an array without key.
There is a difference between defining an array, where you don’t have to specify keys, and printing the array, which gives you a textual representation of the array.
Update: So it seems it has to be
$idis already an array. If you pass it toarray, it will create a new array with the$idas first element.Old answer:
You are already talking about merge. Have you had a look at
array_merge[docs]?Of course,
$args['tags'] = array( $id );does not work. It$args['tags'].$idwhich is already an array, to an array. If$args['tags']does not have a value, you could just do$args['tags'] = $id;.