Title: getting selected strings within another string
Last modified: August 19, 2016

---

# getting selected strings within another string

 *  Resolved [fas.khan](https://wordpress.org/support/users/faskhan/)
 * (@faskhan)
 * [15 years, 5 months ago](https://wordpress.org/support/topic/getting-selected-strings-within-another-string/)
 * Hi,
 * My Plugin is creating a string with the following value.
    `:11:{i:0;s:14:"General
   public";i:1;s:24:"Educational institutions";i:2;s:16:"Large enterprise";i:3;s:
   15:"Local authority";i:4;s:15:"Local community";i:5;s:24:"Professional association";
   i:6;s:25:"Professional organization";i:7;s:20:"Research institution";i:8;s:30:"
   Small and Medium sized company";i:9;s:15:"Training center";i:10;s:30:"Young people
   between 15 and 25";}`
 * Now, I want only these values between the ” “, which are for example:-
 * – General public
    – Educational institutions – Large enterprise – …
 * So basically a function that would allow me to put the values between ” and ”
   into some array.
 * Could you help me building a function in PHP like this? or may be there is some
   built in action which I cant find 🙁
 * Many Thanks

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

 *  [vtxyzzy](https://wordpress.org/support/users/vtxyzzy/)
 * (@vtxyzzy)
 * [15 years, 5 months ago](https://wordpress.org/support/topic/getting-selected-strings-within-another-string/#post-1720631)
 * What you are showing is a ‘serialized’ array. You can ‘unserialize’ it and list
   the entries in a loop. (You are missing the letter ‘a’ at the first of the string.)
 * Assuming that the string is in the variable $list, this will unserialize it and
   list the items:
 *     ```
       $items = unserialize($list);
       echo '<ul>';
       foreach ($items as $item) {
          echo "<li>$item</li>";
       }
       echo '</ul>';
       ```
   
 *  Thread Starter [fas.khan](https://wordpress.org/support/users/faskhan/)
 * (@faskhan)
 * [15 years, 5 months ago](https://wordpress.org/support/topic/getting-selected-strings-within-another-string/#post-1720636)
 * wow! thanks vtxyzzy
 * I was just looking at the string and found a pattern of its appearence …
 * so i did this…
 *     ```
       $adf= (explode('"',$post->options));
   
               		    $i=0;
               		    $len = strlen($adf);
   
               		    for ($i = 0; $i < count($adf); $i++)
                                   {
                                              if ( $i %2 != 0)
               			       	echo $adf[$i]."<br />";
               			   }
       ```
   
 * It just gave me the values.
 * Many Thanks again.
 *  [vtxyzzy](https://wordpress.org/support/users/vtxyzzy/)
 * (@vtxyzzy)
 * [15 years, 5 months ago](https://wordpress.org/support/topic/getting-selected-strings-within-another-string/#post-1720660)
 * Glad you found a solution. Now, please use the dropdown at top right to mark 
   this topic ‘Resolved’.

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

The topic ‘getting selected strings within another string’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 3 replies
 * 2 participants
 * Last reply from: [vtxyzzy](https://wordpress.org/support/users/vtxyzzy/)
 * Last activity: [15 years, 5 months ago](https://wordpress.org/support/topic/getting-selected-strings-within-another-string/#post-1720660)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
