[PHP] Spinn your article

Status
Not open for further replies.

hq320

Active Member
142
2010
31
10
Its very basic code. But maybe someone can use it.

Input:
{Hello|Hi|Hei} {word|wj|google|mate} !

Output:

  • Hei mate !
  • Hi wj !
  • Hi google !
  • Hello word !
spinner.php
PHP:
<?php

    set_time_limit(0);
    if(!isset($_POST['run']))
    {
    
?>


<h1>Spin it.</h1>


<form action="" method="post">
   <label>Your Article:<br>
   <textarea name="content" cols="60" rows="20"></textarea>
   </label><br><br>

   <input type="hidden" name="run" value="run" />
   <input name="submit" type="submit" id="submit" value="SPIN ARTICLE" />   
</form>
<?php 

}else{



function spinner($text) {
    $txt = preg_split("/{|}/", $text);
    foreach($txt as $key => $t){
        if($key%2){
            $spin = preg_split("/\|/", $t);
            $txt[$key] = $spin [mt_rand(1,count($spin)-1)];
        }
    }
    $string = implode("", $txt);
    return $string; 
}  

echo spinner($_POST['content']);

}


?>
 
1 comment
I have tried the spinner; however, I do not see it making any changes to the articles.

Is this just a find and replace?

LitZ
 
Status
Not open for further replies.
Back
Top