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

Anyone 'd like to share a free and simple php content spinner script?

Discussion in 'PHP & Perl' started by tpaolo, Apr 26, 2010.

  1. tpaolo

    tpaolo Regular Member

    Joined:
    May 28, 2009
    Messages:
    333
    Likes Received:
    45
    Hi, I've been looking here and on google for a simple content spinner php script that uses "pipes" to random words/phrases online generation, but dind't found it.

    Also looking for a no professional one, only a script that some php programmer here could have coded without commercial purposes.

    I'd like to add it to my webmaster's resources page for public usage, I can give a backlink to donator.

    Thanks.
     
  2. kaidoristm

    kaidoristm Power Member

    Joined:
    Feb 13, 2009
    Messages:
    561
    Likes Received:
    726
    Occupation:
    Freelancer
    Location:
    Estonia
    Home Page:
    Maybe something like THIS
     
  3. tpaolo

    tpaolo Regular Member

    Joined:
    May 28, 2009
    Messages:
    333
    Likes Received:
    45
    Yes, but I'd like to download it and use it on my site
     
  4. Grizzy

    Grizzy Senior Member

    Joined:
    Nov 11, 2008
    Messages:
    919
    Likes Received:
    999
    Here is a function to do that.
    Code:
    http://www.alexpoole.name/seo/155/simple-php-article-spinner
    Uses commas to delimiter, but could be modified to use pipes.
     
  5. casius

    casius Junior Member

    Joined:
    Apr 18, 2010
    Messages:
    186
    Likes Received:
    20
    Home Page:
    Hello,

    i hope this would help you

    <?php
    mt_srand(crc32($_SERVER['REQUEST_URI'])));
    ?>

    Here?s the function:
    <?php function Spin($txt){
    $test = preg_match_all("#\{(.*?)\}#", $txt, $out);
    if (!$test) return $txt;
    $toFind = Array();
    $toReplace = Array();
    foreach($out[0] AS $id => $match){
    $choices = explode(?|?, $out[1][$id]);
    $toFind[]=$match;
    $toReplace[]=trim($choices[rand(0, count($choices)-1)]);
    }
    return str_replace($toFind, $toReplace, $txt);
    }
    ?>
    You use it like this:
    <?php
    $text = "The {quick|slow|reasonably paced} {brown|green|blue|pink} {fox|goat|rat|camel}
    {jumped|walked|hopped} {over|past|under} the {lazy|tired|boring} {dog|cat|stoat}";
    $count = 0;
    while ($count++ < 100){
    echo Spin($text);
    echo "<br />";
    }
    ?>