Page 1 of 1

Control Statement Variable

Posted: Fri Jan 08, 2010 4:39 am
by pauldr
My question is based upon the following code. In the if-else statement, if $b= $e, does $b in the if section of the control statement now contain the value of $e?

Code: Select all

            do {
                $a = $this->function($c);
                if (array_key_exists('String', $d)) {
                    $a = $b
                } else {
                    $b = $e
                }
            } while ($f <= $g);

Re: Control Statement Variable

Posted: Fri Jan 08, 2010 4:46 am
by aravona
variables

Should do. $var_name = value. You can set one variable value to store anothers value so it should make $b store $e, if all the code works. (in the same way you can do $a = $b + $c etc etc)

Re: Control Statement Variable

Posted: Fri Jan 08, 2010 8:27 am
by pauldr
Thank you, aravona.

Paul

Re: Control Statement Variable

Posted: Mon Jan 11, 2010 5:35 am
by pauldr
I have the following control statement:

Code: Select all

$whois = $this->lookup($a);
if (array_key_exists('OrgName', $whois)) {
      $a = function($ip);
}
$a = function($ip);
How do I get $a from line 3 and line 5 to re-populate $a on line 1 on each recursion?

Paul

Re: Control Statement Variable

Posted: Mon Jan 11, 2010 5:41 am
by aravona
You'd likely get the result you're after with a loop (either for or while) since you want to alter code that occurs earlier.

while loops
for loops