• Hello,

    I have some code

    $following = bp_get_following_ids( $user_id) ;
    print_r (explode(" ",$following));

    which outputs e.g. : Array ( [0] => 2,3,4,5,6,8,14 )

    I would like to use this array in a user query

    $user_query = new WP_User_Query( array( 'include' => array( 1, 2, 3 ) ) );

    where 1,2,3 should be the output of the code above.

    I have tried below, but that seems to be wrong.

    $user_query = WP_User_Query( array( 'include' => explode(",",$following)));

    How can i get the array into the query?

Viewing 1 replies (of 1 total)
  • Moderator Marius L. J.

    (@clorith)

    Hi,

    You need to use the right array element, the dump you did shows that it’s an array with a string in it, so use that

    'include' => explode( ',', $following[0] ) is the same as your initial example 🙂

    Edit: Was thinking wrong, fixed it 🙂

Viewing 1 replies (of 1 total)
  • The topic ‘Array into variable’ is closed to new replies.