• Sign Up
    • OpenID
    • Google
    • Yahoo!
    • Facebook
    • Ning
  • Discuss
  • New Topic
  • Categories
  • Forum
  • Debate
  • Languages
    • English
    • Finnish
    • Arabic
    • Italian
    • Korean
    • French
    • Chinese(Traditional)
    • Chinese(Simplified)
    • Swedish
    • Czech
    • Hindi
    • Dutch
    • Norwegian
    • Russian
    • Croatian
    • German
    • Japanese
    • Bulgarian
    • Portuguese
    • Chinese
    • Spanish
    • Greek
  • Login

Ok

Ads

affordable seo

Ask a Question



Welcome New Members!

zhangwigs

chandan...

jimmy b...

moneyma...

stacyjohn

Emile

Tiffany

CBIL360

Lawsons

christi...

meiwei

kingkhan

brendaj...

swati

sunnyjohn

conniejohn

sunnyping

fengmi

califor...

hengjiao


Hot Topics

array code column content Custom database drupal element field file form function index jquery module MySQl node page PHP query server something SQL string table theme time user VALUE way

 

 

 

Reason

 

PHP Spintax Function - The PHP Spinner!

Joesph

Joesph
I found this great code on the net to spin text, a PHP Spintax function. The function is incredibly easy and just as easy to use. 

/*
 * Take some text and spin it, then return
 * spun verison.
 */

function ParseSpinText($s) {
        preg_match('{(.+?)}#is',$s,$m);
        if(empty($m)) return $s;

        $t = $m[1];

        if(strpos($t,'{')!==false){
                $t = substr($t, strrpos($t,'{') + 1);
        }

        $parts = explode("|", $t);
        $s = preg_replace("+{".preg_quote($t)."}+is", $parts[array_rand($parts)], $s, 1);

        return ParseSpinText($s);
}
 


Usage
//Example:
echo ParseSpinText('{This|Here} is {some|a {little|wee} bit of} {example|sample} text.');


Origianl Source Here

I will promote your business,brand,website,product, etc to my 12,000+ members on facebook within 1 day for $14


In PHP | 2 Replies | 5873 Views | 1 month ago
spinner spin spintext
  • Report Abuse
  • Email
  • Add to Favorites

Rate Now:   1 2 3 4 Average Rating: 0.00 / 2 ratings


Replies:

Guest

Guest
Thanks for nice snippet. It served my purpose though I needed to change the syntax of regex :).

  • Reply to Answer
  • 1 month ago
  • Report Abuse
  • By Guest

Rate Now: 1 2 3 4 Average Rating: 0.00 / 0 ratings

Replied by Guest 1 month ago

Guest

Guest
here is the link to my php spintax class
http://ronaldarichardson.com/2011/...intax-class-2-5/

  • Reply to Answer
  • 1 month ago
  • Report Abuse
  • By Guest

Rate Now: 1 2 3 4 Average Rating: 0.00 / 0 ratings

Replied by Guest 1 month ago


Your Response:

Join

Login


 

Related Questions

SELECT (function()).*;
0 Answers | 3391 Views
How do I call a class function without making an instance of the class?
2 Answers | 2400 Views
Get Function name of where function was called from?
0 Answers | 2823 Views
Is there a printf-like string function in postgresql?
0 Answers | 3709 Views
Is there a PHP function that will return an array of all of my uploaded ima...
1 Answer | 3321 Views
Disclaimer | Privacy Policy | Terms | ■ RSS | Sitemap | Contact Us | ■ Invite | Create your Widget | ■ Twitter | ■ Facebook
© 2013 PHPInformer. All rights reserved

PHPInformer does not evaluate or guarantee the accuracy of any PHPInformer content. Click here for the Full Disclaimer.