GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   Google will love you. (https://gfy.com/showthread.php?t=1120799)

Vapid - BANNED FOR LIFE 09-10-2013 03:30 PM

Google will love you.
 
Code:

function spin($pass){
    $mytext = $pass;
    while(inStr("}",$mytext)){
        $rbracket = strpos($mytext,"}",0);
        $tString = substr($mytext,0,$rbracket);
        $tStringToken = explode("{",$tString);
        $tStringCount = count($tStringToken) - 1;
        $tString = $tStringToken[$tStringCount];
        $tStringToken = explode("|",$tString);
        $tStringCount = count($tStringToken) - 1;
        $i = rand(0,$tStringCount);
        $replace = $tStringToken[$i];
        $tString = "{".$tString."}";
        $mytext = str_replaceFirst($tString,$replace,$mytext);
    }
    return $mytext;
}

Code:

$s = spin("{spin|spun} {stuff|shit}");
Code:

echo $s;

valeriyCE 09-10-2013 03:41 PM

you mean strpos right and not inStr?

_Richard_ 09-10-2013 04:23 PM

is this from a BHW thread from 2011?

_Richard_ 09-10-2013 04:26 PM

another option:

PHP Code:

function spin($s) { 
    return 
preg_replace_callback
        
'|\{(.*?)\}|'
        function (
$m) { 
            
$e explode('|',$m[1]); 
            return 
$e[array_rand($e)]; 
        }, 
        
$s 
    
); 




All times are GMT -7. The time now is 12:41 AM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123