Technology Programming

How to Spin With PHP

  • 1). Paste the following PHP code to use as a template for your spinner project:

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

    }

    ?>

  • 2). Add the following code below to run your spinner project. The code will create two functions: the spin function and the replacement line for the first instance of a string:

    <?php

    $text = "The {fast|timid| reluctantly slow} {red|green|purple|pink} {fox|sheep|moose|camel}

    {jumped|walked|hopped} {over|past|under} the {sleepy|exhausted|boring} {dog|cat|goat}";

    $count = 0;

    while ($count++ < 100){

    echo Spin($text);

    echo "<br />";

    }

    ?>

    This code will produce various funny yet beneficial spin combinations for your subject in terms of SEO, such as:

    The fast red fox walked over the sleepy dog

    The timid green sheep walked under the exhausted goat

    The reluctantly slow pink moose hopped over the boring cat

  • 3). Paste the code below to keep your PHP spinner project nested in its designated spot:

    $string = '{{A {{common|basic}} example|An uncomplicated scenario|The {{plain|trivial|elementary|rudimentary}} case|My {{analysis|invest{{igative|igation}}}} case}} to illustrate the {{problem|issue}}';

    echo '<p>';

    for($i = 1; $i <= 5; $i++)

    {

    echo Spinner::detect($string, false).'<br />';

    // or Spinner::nested($string, false).'<br />';

    }

    echo '</p>';

SHARE
RELATED POSTS on "Technology"
WordPress - How to Set up a New Theme to WordPress 3.
WordPress - How to Set up a New Theme to WordPress 3.
Solution of Creative Web Design
Solution of Creative Web Design
The three disciplines of User Experience
The three disciplines of User Experience
Web Design Sheffield Options For Professional Enterprises
Web Design Sheffield Options For Professional Enterprises
Do you have what it takes?
Do you have what it takes?
Segway Cost
Segway Cost
Microsoft Access 2010: What's Coming with Office 2010?
Microsoft Access 2010: What's Coming with Office 2010?
Companies of Web Development in Ireland Provide Designs that Work
Companies of Web Development in Ireland Provide Designs that Work
Penguin Update to Put Red-Flags on Negative SEO
Penguin Update to Put Red-Flags on Negative SEO
Innovative web 2 design templates can make your business famous quickly
Innovative web 2 design templates can make your business famous quickly
Building A Search Engine Friendly Website
Building A Search Engine Friendly Website
Exceptional Advice To Build Up Your Internet Marketing
Exceptional Advice To Build Up Your Internet Marketing
The Benefits of Selecting The Right Hosting Company
The Benefits of Selecting The Right Hosting Company
Is There a Methodology for Making Successful Logos
Is There a Methodology for Making Successful Logos
Benefits of Ruby On Rails Development
Benefits of Ruby On Rails Development
The Power of Colour and Shapes in Your Infant's Life.
The Power of Colour and Shapes in Your Infant's Life.
Advantages of Hiring PSD To HTML Service Providers
Advantages of Hiring PSD To HTML Service Providers
How to Make Responsive Web Design Attractive?
How to Make Responsive Web Design Attractive?
Converting PSD to Responsive HTML
Converting PSD to Responsive HTML
Just a few realy really hints and tips when it comes to website design but look for.
Just a few realy really hints and tips when it comes to website design but look for.

Leave Your Reply

*