...

View Full Version : Resolved Assigning a variable to an echoed string



wldrumstcs
02-24-2010, 04:59 PM
I have a function called whatToDo(). In the function, it echoes a string like "Hit" or "Split" (it's a Blackjack program). I need to set a variable to whatever whatToDo() echoes, but all my current code does is echo, not set the variable to what's being echoed. How do I set the variable without anything being echoed? In the code below, setting $haystack just echoes whatToDo(), it doesn't get set to "hit";

code:


function haystack($whichDeck)
{
// for simplicity's sake, we will just pretend this function echoes "Hit" every time
echo "Hit";
}

$haystack = strtolower(whatToDo($_GET["whichDeck"]));
if(substr_count($haystack,"hit") > 0) // the player should hit
{
setGrade($_SESSION["grade"]+1);
setPossibleGrade($_SESSION["possibleGrade"]+1);
}
else
setPossibleGrade($_SESSION["possibleGrade"]+1);

MattF
02-24-2010, 05:04 PM
function haystack($whichDeck)
{
return 'Hit';
}

wldrumstcs
02-24-2010, 05:15 PM
Sweet mother of god I'm an idiot. I guess that's what 3 hours of sleep will do to you. Thanks.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum