Title: Pasing String
Last modified: August 19, 2016

---

# Pasing String

 *  Resolved [MaddTechWF](https://wordpress.org/support/users/maddtechwf/)
 * (@maddtechwf)
 * [15 years ago](https://wordpress.org/support/topic/pasing-string/)
 * I have a custom Metabox. It allows multiple words separated by a ,. How can I
   write a loop to write each item to a UL list?

Viewing 3 replies - 1 through 3 (of 3 total)

 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [15 years ago](https://wordpress.org/support/topic/pasing-string/#post-2074735)
 * `explode` the string to form an array; then loop with a `foreach` loop.
 * [http://php.net/manual/en/function.explode.php](http://php.net/manual/en/function.explode.php)
   
   [http://php.net/manual/en/control-structures.foreach.php](http://php.net/manual/en/control-structures.foreach.php)
 * example:
 *     ```
       $string = from metabox, use whatever code
       $bits = explode(',', $string);
         if($bits) {
           echo '<ul>';
             foreach( $bits as $bit ) {
             echo '<li>'.bit.'</li>';
             }
           echo '</ul>';
         }
       ```
   
 *  Thread Starter [MaddTechWF](https://wordpress.org/support/users/maddtechwf/)
 * (@maddtechwf)
 * [15 years ago](https://wordpress.org/support/topic/pasing-string/#post-2074750)
 * When I implement the above code, I get the word bit on each one of my list items.
   What am I doing wrong?
 *  Thread Starter [MaddTechWF](https://wordpress.org/support/users/maddtechwf/)
 * (@maddtechwf)
 * [15 years ago](https://wordpress.org/support/topic/pasing-string/#post-2074796)
 * Found it. Forgot the $ between the . and the b.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Pasing String’ is closed to new replies.

 * 3 replies
 * 2 participants
 * Last reply from: [MaddTechWF](https://wordpress.org/support/users/maddtechwf/)
 * Last activity: [15 years ago](https://wordpress.org/support/topic/pasing-string/#post-2074796)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
