• Resolved sniperkill

    (@sniperkill)


    Hello

    I need little pointer and don’t know where I am doing wrong.

    in my XML file, The bedrooms have value like this 2|2|2 . Value is showing 3 times, I want to keep only first one.

    In php function Editor, I am using below code

    <?php
    
    function bedroom_fix($bedrooms){
    
    $new_value = explode("|", $bedrooms);
    
    return $new_value[0];
    
    }
    
    ?>
    

    how to put result of $new_value[0]; in import process ? Sorry I am new to php and don’t know where I am doing wrong.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter sniperkill

    (@sniperkill)

    I have realised that by using $bedrooms in php editor, It wont take values of bedrooms from XML file, Still figuring out how to call values of bedrooms from XML to PHP editor.

    • This reply was modified 7 years, 11 months ago by sniperkill.
    Thread Starter sniperkill

    (@sniperkill)

    
    function bedroom_fix(){
    	
    	$new = explode("|",$bedrooms);
    	$bedroom = $new[0];
    	return $bedroom;
    	
    	
    }
    

    The above code is also not working, Any help would be appreciated.

    Thanks

    • This reply was modified 7 years, 11 months ago by sniperkill.
    Plugin Author WP All Import

    (@wpallimport)

    Hi @sniperkill

    You’ll need to pass the import element to your function, for example:

    [my_parse_bedrooms({bedrooms[1]})]

    Then, use code like this to return the first one:

    function my_parse_bedrooms( $bedrooms ) {
    	$bedrooms = explode( "|", $bedrooms );
    	return reset( $bedrooms );
    }

    Read more on PHP functions in imports here: http://www.wpallimport.com/documentation/developers/execute-php/.

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

The topic ‘Function Editor help’ is closed to new replies.