Easy Auto-generated Comments in PHP

Knowing how to auto-generate content is a huge timesaver. A while back, I needed to come up with a bunch of comments for a group of blogs I was building. Rather than outsource it to a real person, I decided to see if I could some up with a way to automate it. What you see below is my proof of concept.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php
// Madlib Style Fake Comment Script
// http://ctrtard.com -- 9-17-2010
 
$madlib['good job'] = array ("good job", "nice work", "nicely done!", "excellent work!", "great job!");
$madlib['post'] = array ( "post", "article", "write up", "blog post", "piece");
$madlib['great'] = array ( "great", "amazing", "fantastic", "excellent", "solid" );
$madlib['thanks'] = array ( "thanks", "thank you", "thanks so much", "thank you so much");
$madlib['looking for'] = array ( "looking for", "looking everywhere for", "searching for", "searching everywhere for", "hoping for", "hoping to find" );
$madlib['info'] = array ( "info", "information");
 
 
$comment[] = "{great} {post}!";
$comment[] = "{great} {post}! {thanks}!";
$comment[] = "{great} {post}! {thanks} for this {info}!";
$comment[] = "{great} {post}! I've been looking for this {info}. {thanks}!";
$comment[] = "{great} {info}.";
$comment[] = "{great} {info}. {thanks}!";
$comment[] = "I've been {looking for} this {info} for quite some time.";
$comment[] = "{thanks} for this!";
$comment[] = "{thanks} for this {great} {post}!";
 
for($i=0;$i<=5;$i++){
    for($c=0;$c< count($comment) ;$c++){
        $content = $comment[$c];
        foreach( $madlib as $seed => $spins){
            $content = str_replace("{" . $seed. "}", $spins[ rand(0, count($spins)-1)], $content );
        }
        $content = ucfirst($content);
        echo $content. "<br>";
    }
}            
?>

The script works using a madlib style — this same technique is used by most of the so-called “article spinners” on the market. When you check out the code, you will see a top section that let’s you define a “token” and add variations (synonyms or phrases) for this token.

The second section let’s you write out a comment using these tokens.  By writing in in a natural way, you can see it’s easy to come up with sentence variations.

The third section is a loop that does the actual spinning.  I simply made it output each comment 5 times.

This script does not check for duplicate output, but that’s easily added.

You can tie this into other scripts (hint: Poor Man’s Fake User Reviews)  and get some really sweet unique content in seconds.  Or you can use it as-is and simply copy & paste results into your landing pages.

Here is some sample output:

Great blog post!
Solid blog post! thanks so much!
Excellent piece! thanks so much for this info!
Great post! I’ve been looking for this information. thank you!
Excellent information.
Excellent info. thank you!
I’ve been searching everywhere for this info for quite some time.
Thank you for this!
Thanks for this solid post!
Amazing blog post!
Fantastic post! thanks so much!
Great piece! thanks so much for this info!
Great write up! I’ve been looking for this info. thanks!
Excellent info.
Excellent information. thanks!
I’ve been looking everywhere for this info for quite some time.
Thank you so much for this!
Thanks for this fantastic write up!
Fantastic article!
Great piece! thanks so much!
Great article! thanks so much for this information!
Fantastic article! I’ve been looking for this info. thanks so much!
Great info.
Amazing info. thank you so much!
I’ve been looking everywhere for this information for quite some time.
Thank you for this!
Thanks so much for this amazing article!
Fantastic piece!
Amazing article! thank you!
Great post! thank you for this info!
Excellent article! I’ve been looking for this information. thanks!
Fantastic info.
Excellent info. thank you so much!
I’ve been hoping to find this info for quite some time.
Thanks so much for this!
Thanks for this great piece!
Amazing blog post!
Amazing write up! thank you!
Amazing article! thanks for this information!
Solid blog post! I’ve been looking for this info. thank you so much!
Fantastic information.
Amazing info. thank you so much!
I’ve been searching everywhere for this information for quite some time.
Thank you so much for this!
Thank you for this fantastic article!
Amazing write up!
Excellent post! thanks so much!
Excellent blog post! thanks for this information!
Excellent article! I’ve been looking for this information. thank you!
Amazing info.
Fantastic information. thanks!
I’ve been hoping for this information for quite some time.
Thank you for this!
Thank you for this solid post!

As you can see, it works pretty well and it would be simple to make it generate even more variations by making a few changes to those top sections.

Have fun!

Leave a comment

Leave a Reply to Josh Delcore Cancel reply.

*

*

CommentLuv badge
Cancel reply

9 Comments

  • Great blog post!

    Hey it works!

    😉

    Really though, this is a slick script, thanks a lot for sharing it. When I need some comments, I’m using this for sure.

    • Glad you like it. Now get out there and make some fake content!

  • Ethan

    Great blog post!
    Solid blog post! thanks so much!
    Excellent piece! thanks so much for this info!
    Great post! I’ve been looking for this information. thank you!
    Excellent information.
    Excellent info. thank you!
    I’ve been searching everywhere for this info for quite some time.
    Thank you for this!
    Thanks for this solid post!
    Amazing blog post!
    Fantastic post! thanks so much!
    Great piece! thanks so much for this info!
    Great write up! I’ve been looking for this info. thanks!
    Excellent info.
    Excellent information. thanks!
    I’ve been looking everywhere for this info for quite some time.
    Thank you so much for this!
    Thanks for this fantastic write up!
    Fantastic article!
    Great piece! thanks so much!
    Great article! thanks so much for this information!
    Fantastic article! I’ve been looking for this info. thanks so much!
    Great info.
    Amazing info. thank you so much!
    I’ve been looking everywhere for this information for quite some time.
    Thank you for this!
    Thanks so much for this amazing article!
    Fantastic piece!
    Amazing article! thank you!
    Great post! thank you for this info!
    Excellent article! I’ve been looking for this information. thanks!
    Fantastic info.
    Excellent info. thank you so much!
    I’ve been hoping to find this info for quite some time.
    Thanks so much for this!
    Thanks for this great piece!
    Amazing blog post!
    Amazing write up! thank you!
    Amazing article! thanks for this information!
    Solid blog post! I’ve been looking for this info. thank you so much!
    Fantastic information.
    Amazing info. thank you so much!
    I’ve been searching everywhere for this information for quite some time.
    Thank you so much for this!
    Thank you for this fantastic article!
    Amazing write up!
    Excellent post! thanks so much!
    Excellent blog post! thanks for this information!
    Excellent article! I’ve been looking for this information. thank you!
    Amazing info.
    Fantastic information. thanks!
    I’ve been hoping for this information for quite some time.
    Thank you for this!
    Thank you for this solid post!

  • Wow Great…! You give us very knowledge about PHP it will increase ranking very fast.
    Thank You.

  • Sweet code! Thank you!

  • Victor Alderman

    Hey Retard….im in the MBX forums etc with ya. thought i’d check out your site and it really [put a smile on my face.
    nice script too!! NOT generated by your script seal :()

  • Damn, you have some sweet free scripts for SEO! I can’t wait to see what you come up with next! I have been doing search engine optimization and affiliate marketing for a while, but it is great to finally find a place to find other webmasters to get tips and become more productive. Thanks again!

    • Glad you liked it. More SEO, less smoking crack.

  • It would be great to me, but I do not understand how it works.

 
 
 

Related posts by category

Related posts by tag