Article Spinning Script

Trying to get this article spinning script to work, not sure what I am doing wrong… keep in mind I am new to this…

<html>
<head>
<title>test</title>
</head>
<body>
<form method="post" action="spin.php">
  Message:<br />
  <textarea id="txt" name="txt" rows="15" cols="40">
  </textarea><br />
  <input type="submit" />
</form>
</body>
</html>

[php]

<?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); } ?>

[/php]

If you try to use the form it just shows up blank… if you try and manually enter text in the code and just run the code it comes up with an error.

Well, you have a function written in php Spin(), but I do not see where do you make a call to this function? What is the code in your spin.php file?

I guess your entire code should look similar to this:

spin.php
[php]

test Message:

<?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);

}

if(isset($_POST[‘txt’])){
echo ‘


Result:
’;
echo Spin($_POST[‘txt’]);
}
?> [/php]

I see this returning a result. I was trying to do it as two separate files but this is working better lol. Its not actually spinning the text though… this should be the format of how its typed in to spin… {word1|word2|word3}

it now just posts directly below the form with: word1|word2|word3

Sponsor our Newsletter | Privacy Policy | Terms of Service