...

View Full Version : Porblem with "gluing" variables together in if statement..



cyphix
05-16-2004, 01:13 AM
I'm about to pull my hair out here..



while ($textpc <= $textlp) {

if ($fmtextq . $textpc == "") {

echo "Please make sure all questions are filled in before submitting. Thanks!";

exit();

}

$textpc++;

}


Ok, I can not pull the correct value in that if statement.... I can get the value to print out correctly if I echo it; but I can't get it working in that if statement.... any help here? I've been trying several different things over the last hour or more & I'm about to pull my hair out!! :mad:

raf
05-16-2004, 01:51 AM
maybe tell us what you are trying to do instead of yet another cryptic post with some strange code ...

using my psychic powers, i think you're looking for

if (${'fmtextq' . $textpc} == "") {

cyphix
05-16-2004, 12:06 PM
Your psychic powers worked! ;)

raf
05-16-2004, 10:43 PM
What can i say ...

It's actualy rather hard to find in the manual. Especially if the first part of the variablename needs to be some fixed text where you then glue the valu from a variable to. I found it out initially by just experimenting with all possible syntaxpossebilitys.

Most coders would use
$varname = 'fmtextq' . $textpc
if ($$varname == "") {



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum