Control Statement Variable

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
pauldr
Forum Newbie
Posts: 18
Joined: Fri Apr 10, 2009 6:40 am

Control Statement Variable

Post 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);
aravona
Forum Contributor
Posts: 347
Joined: Sat Jun 13, 2009 3:59 pm
Location: England

Re: Control Statement Variable

Post 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)
pauldr
Forum Newbie
Posts: 18
Joined: Fri Apr 10, 2009 6:40 am

Re: Control Statement Variable

Post by pauldr »

Thank you, aravona.

Paul
pauldr
Forum Newbie
Posts: 18
Joined: Fri Apr 10, 2009 6:40 am

Re: Control Statement Variable

Post 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
aravona
Forum Contributor
Posts: 347
Joined: Sat Jun 13, 2009 3:59 pm
Location: England

Re: Control Statement Variable

Post 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
Post Reply