Title: PHP replace command
Last modified: August 30, 2016

---

# PHP replace command

 *  Resolved [giallo1993](https://wordpress.org/support/users/giallo1993/)
 * (@giallo1993)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/php-replace-command/)
 * I have WP All Import Pro!
    Ik want to replace a tekst in 3 of the field in the
   downloaded XML.
 * I created a PHP entry in the import-definition like
    <?php [str_replace(“Dames“,“”,
   fields[1]/CategorieOmschrijving[1])] [str_replace(“Dames “, “”, fields[1]/ShopOmschrijving[
   1])] [str_replace(“Dames “, “”, fields[1]/KenmerkadviseurOmschrijving[1])] ?>
 * For some kind of reason this doesn’t work
 * Example: fieldvalue ‘Dames Schoenen’ should be ‘Schoenen’
    I don’t want to use‘
   mapping’ because there are 100+ possible value’s
 * Please help
 * [https://wordpress.org/plugins/wp-all-import/](https://wordpress.org/plugins/wp-all-import/)

Viewing 1 replies (of 1 total)

 *  Plugin Author [WP All Import](https://wordpress.org/support/users/wpallimport/)
 * (@wpallimport)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/php-replace-command/#post-6674766)
 * Where are you entering this? Why have you included php open/close tags?
 * If you want to write a custom function to create your own mapping rules, you 
   should:
 * 1) Write a custom function that passes your category data through all of your
   str_replace filters
 * 2) Pass all of your categories through that one function.
 * Using the above example, your function would be:
 *     ```
       function no_dames( $str ) {
   
           $str = str_replace( "Dames ", "", $str );
           return $str;
   
       }
       ```
   
 * If you wanted to filter out something else as well, you’d modify your function
   like so:
 *     ```
       function no_dames( $str ) {
   
           $str = str_replace( "Dames ", "", $str );
           $str = str_replace( "something else ", "", $str );
           return $str;
   
       }
       ```
   
 * Then to import your category you’d enter `[no_dames({fields[1]/KenmerkadviseurOmschrijving[
   1]})]` into the category import section.
 * Note that the code above is untested and for example purposes, and that the XML
   node being passed into the no_dames function may not be correct. You can read
   more about custom functions here: [http://www.wpallimport.com/documentation/developers/execute-php/](http://www.wpallimport.com/documentation/developers/execute-php/)
 * If you need any additional help with this please submit a support request: [http://www.wpallimport.com/support/](http://www.wpallimport.com/support/)

Viewing 1 replies (of 1 total)

The topic ‘PHP replace command’ 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

 * [php](https://wordpress.org/support/topic-tag/php/)
 * [str_replace](https://wordpress.org/support/topic-tag/str_replace/)

 * 1 reply
 * 2 participants
 * Last reply from: [WP All Import](https://wordpress.org/support/users/wpallimport/)
 * Last activity: [10 years, 5 months ago](https://wordpress.org/support/topic/php-replace-command/#post-6674766)
 * Status: resolved