• Resolved pnbnsv

    (@pnbnsv)


    Hi there,

    I am trying to create a PHP function to replace part of the string of a value in a field to export. The values in that field are like “Referência R999999” and I just want to remove the “Referência ” part and let the rest as it is. I tried this but doesn’t work:

    function corrige_referencia($ref) {
    str_replace(“Referência “,””,”$ref”);
    }

    Any help, please?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author WP All Import

    (@wpallimport)

    Hi @pnbnsv

    Please try the following code instead:

    function corrige_referencia( $ref ) {
    	$ref = str_replace( "Referência ", "", $ref );
    	return $ref;
    }
    Thread Starter pnbnsv

    (@pnbnsv)

    Hi,

    I am using:

    <?php
    function corrige_referencia($ref) {
    return str_replace(“Referência “,””,$ref);
    }
    ?>

    And it works.

    Thank you very much for your help!

    @pnbnsv, please, don’t forget to mark this ticket as solved.
    (márcalo como resuelto así sirve para los demás usuarios 😉 ).

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

The topic ‘Function to replace part of string’ is closed to new replies.