first commit
This commit is contained in:
44
autoload/class.SEOMixer.php
Normal file
44
autoload/class.SEOMixer.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
class SeoMixer
|
||||
{
|
||||
public $input;
|
||||
public $output;
|
||||
public $limit = 1;
|
||||
private $braces = array("{", "}");
|
||||
private $delimiter = "|";
|
||||
|
||||
function __construct($input)
|
||||
{
|
||||
$this->input = $input;
|
||||
}
|
||||
|
||||
function mixAll()
|
||||
{
|
||||
$this->output = $this->input;
|
||||
while (strpos($this->output, $this->braces['1']) !== false)
|
||||
{
|
||||
$closed = strpos($this->output, $this->braces['1']);
|
||||
$substr = substr($this->output, 0, $closed + 1);
|
||||
$from = strrpos($substr, $this->braces['0']);
|
||||
$substr = substr($substr, $from);
|
||||
$_substr = $this->mixText($substr);
|
||||
$this->output = str_replace($substr, $_substr, $this->output);
|
||||
$substr = "";
|
||||
$_substr = "";
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
function mixText($text)
|
||||
{
|
||||
$text = str_ireplace($this->braces, "", $text);
|
||||
$elements = explode($this->delimiter, $text);
|
||||
return $elements[array_rand($elements)];
|
||||
}
|
||||
function mix()
|
||||
{
|
||||
$this->mixAll();
|
||||
return $this->output;
|
||||
}
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user