Title: Nested Spin function
Last modified: January 13, 2020

---

# Nested Spin function

 *  Resolved [ricardl](https://wordpress.org/support/users/ricardl/)
 * (@ricardl)
 * [6 years, 4 months ago](https://wordpress.org/support/topic/nested-spin-function/)
 * Hello,
 * I have been doing good with the spin formula posted here: [https://paste.ee/p/GluOL](https://paste.ee/p/GluOL)
 * But, in my case I need to spin more words (synonyms) inside spintax, so I’d need
   to implement a nested spin. However, the formula I usually apply in php is not
   working in Wp All Import.
    This is the formula:
 * <?PHP
    class Spintax { public function process($text) { return preg_replace_callback(‘/\{(((?
   >[^\{\}]+)|(?R))*)\}/x’, array($this, ‘replace’), $text ); } public function 
   replace($text) { $text = $this->process($text[1]); $parts = explode(‘|’, $text);
   return $parts[array_rand($parts)]; } }
 * How can I adapt it to WP All Import??
 * Thank you for this awesome Plugin. Best Regards,

Viewing 1 replies (of 1 total)

 *  Plugin Author [WP All Import](https://wordpress.org/support/users/wpallimport/)
 * (@wpallimport)
 * [6 years, 4 months ago](https://wordpress.org/support/topic/nested-spin-function/#post-12341801)
 * Hi [@ricardl](https://wordpress.org/support/users/ricardl/)
 * > How can I adapt it to WP All Import??
 * You can make the functions outside of a class, e.g.:
 *     ```
       function my_process_spintax( $text ) {
       	return preg_replace_callback( '/\{(((?>[^\{\}]+)|(?R))*)\}/x', 'my_replace_spintax', $text );
       }
   
       function my_replace_spintax( $text ) {
       	$text = my_process_spintax( $text[1] );
       	$parts = explode( '|', $text );
       	return $parts[ array_rand( $parts ) ];
       }
       ```
   
 * Then pass the spintax to the my_process_spintax function:
 * `[my_process_spintax({spintax[1]})]`

Viewing 1 replies (of 1 total)

The topic ‘Nested Spin function’ is closed to new replies.

 * ![](https://ps.w.org/wp-all-import/assets/icon-256x256.png?rev=2570179)
 * [WP All Import – Drag & Drop Import for CSV, XML, Excel & Google Sheets](https://wordpress.org/plugins/wp-all-import/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-all-import/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-all-import/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-all-import/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-all-import/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-all-import/reviews/)

## Tags

 * [nested](https://wordpress.org/support/topic-tag/nested/)
 * [spin](https://wordpress.org/support/topic-tag/spin/)

 * 1 reply
 * 2 participants
 * Last reply from: [WP All Import](https://wordpress.org/support/users/wpallimport/)
 * Last activity: [6 years, 4 months ago](https://wordpress.org/support/topic/nested-spin-function/#post-12341801)
 * Status: resolved