[SOLVED] Can a PHP spinner work on page reloads instead of clicking a button?

by Thomas
3 replies
Hello Warriors:

I've come across several examples of PHP scripts that will spin blocks of text (just like any article spinner). However, they all require manual interaction for each spin (i.e. "Click here to spin").

Does anyone know if it's possible to do the same thing on every page reload instead? (By that, I mean it still does the same thing, but the trigger is the reload, instead of clicking a button).

Tommy.
#button #clicking #page #php #reloads #spinner #work
  • Profile picture of the author SteveJohnson
    It shouldn't be difficult to modify one of the scripts to work on page reload instead of a form submit, it just depends on how they are written in the first place.
    Signature

    The 2nd Amendment, 1789 - The Original Homeland Security.

    Gun control means never having to say, "I missed you."

    {{ DiscussionBoard.errors[5020403].message }}
    • Profile picture of the author Marketing Fool
      Yeah I do that...it's no big deal....just depends on the specific script you're working with.

      If you can't do it yourself...you could probably just pay someone a few bucks to show you how or modify a specific script.
      Signature
      Learn to CODE at Codemy.com - It's Pretty Awesome!
      {{ DiscussionBoard.errors[5022214].message }}
  • Profile picture of the author Thomas
    Thanks for the replies; I got it to work prior to coming back to check this thread (it's rather easy, as it turns out .

    Here's the end result:
    function spin($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 spin($s);
    }

    echo htmlentities(spin('TEXT TO SPIN'));
    It seems to work just fine.

    Tommy.

    P.S. - I used the htmlentities function because the spun text will be displayed in a text area with html code that I don't want rendered in the browser.
    {{ DiscussionBoard.errors[5025954].message }}

Trending Topics