Calling Functions (displaying contents of) in another fx
Posted: Wed Jun 30, 2010 12:15 pm
Hey Guys, Here's my code:
What I need to do is call the results of the $spin2 function (ie: #1, #2 etc) and the results of $speak (ie: interesting failure etc...) into a new function using the same spin code:
$awesome = $spin('{$spin2|$speak}');
so that $awesome will return either "#1" OR "awesome method" etc...
Right now, using the code above, I get a result returned of the actual function
ie: the echo is "$spin2" or "$speak" instead of the results OF the function.
Hopefully this makes sense, and hopefully someone can give me some useful code here.
Thanks ahead of time!!
Code: Select all
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);
}
$spin2 = spin('{#1|#2|#3|#4|#5|#6|#7|#8|#9|#10|#11|#12|#13|#14|#15|#16|#17|#18|#19|#20}');
$speak = spin('{interesting|awesome|amazing|cool|informative|wierd|dope|wicked|neat|swell|inspiring|audacious|fullfilling|kickass|super cool} {site|page|article|link|file|place|zone|method|failure|success story|tactic}');
$awesome = $spin('{$spin2|$speak}');
so that $awesome will return either "#1" OR "awesome method" etc...
Right now, using the code above, I get a result returned of the actual function
ie: the echo is "$spin2" or "$speak" instead of the results OF the function.
Hopefully this makes sense, and hopefully someone can give me some useful code here.
Thanks ahead of time!!