1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Anyone have a spintax script?

Discussion in 'PHP & Perl' started by FuryFit, Dec 13, 2011.

  1. FuryFit

    FuryFit Regular Member

    Joined:
    Oct 19, 2011
    Messages:
    206
    Likes Received:
    33
    I'm looking for a script I can include in my site's template, which will read an article in spintax and output the spun version when the page is viewed.

    It could be CPU intensive but i figure it will be ok once most of the affected urls are cached.
     
  2. weedsmoker

    weedsmoker Junior Member

    Joined:
    May 2, 2011
    Messages:
    190
    Likes Received:
    79
    Which programming language?
    Here's PHP function i use, it supports nested spintax. Grab article with $spintext = file_get_contents( $path_to_article ).

    PHP:
    function spintext_spin$spintext )
    {
        
    preg_match'#\{(.+?)\}#is'$spintext$tmp );
        if( empty( 
    $tmp ) ): return $spintext; endif; # >>>
        
    $tmp $tmp[1];
        if( 
    strpos$tmp'{') !== false ):
            
    $tmp substr$tmpstrrpos$tmp'{' ) + );
        endif;
        
    $parts explode'|'$tmp );
        
    $spintext preg_replace"+\{" preg_quote$tmp ) . "\}+is"$parts[array_rand$parts )], $spintext);
        return 
    spintext_spin$spintext );
    }
     
    • Thanks Thanks x 1
  3. FuryFit

    FuryFit Regular Member

    Joined:
    Oct 19, 2011
    Messages:
    206
    Likes Received:
    33
    I preferred PHP - thanks that's what i needed.
     
  4. randolph60

    randolph60 Junior Member

    Joined:
    May 13, 2011
    Messages:
    191
    Likes Received:
    48
    Are you sure that there's no Plugin with this function?

    Search for Spintax using WP Plugin search. As i can remember, i found one in past.