Title: Array into variable
Last modified: August 30, 2016

---

# Array into variable

 *  [eGuard](https://wordpress.org/support/users/eguard/)
 * (@eguard)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/array-into-variable/)
 * 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.](https://wordpress.org/support/users/clorith/)
 * (@clorith)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/array-into-variable/#post-6573518)
 * 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.

## Tags

 * [array](https://wordpress.org/support/topic-tag/array/)
 * [query](https://wordpress.org/support/topic-tag/query/)
 * [user query](https://wordpress.org/support/topic-tag/user-query/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 2 participants
 * Last reply from: [Marius L. J.](https://wordpress.org/support/users/clorith/)
 * Last activity: [10 years, 8 months ago](https://wordpress.org/support/topic/array-into-variable/#post-6573518)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
