Array unreadable inside nested foreach 
Author Message
 Array unreadable inside nested foreach

Has anybody found that by using a nested foreach, that an array or other
variable, defined
outside the nest, in an include file, is not seen inside the nest?

Thus in xyz.php, a single variable is defined like so

$myKey="randell";

Then, in my controling program, I have the following

<?
include("xyz.php");

// the value of $myKey is visable here.
print("myKey is visable here and has a value of $myKey");

$a[]="one";
$a[]="two";
$b[]="apple";
$b[]="orange";

// the value of $myKey is NOT visable below
foreach($a as $keyA=>$valueA)
{
    foreach($b as $keyB=>$valueB)
    {
        print("$keyA = $keyB and myKey is no longer visable as $myKey");
    }

Quote:
}

?>

Anybody any ideas? Is this a bug? I'm devleoping with Dreamweaver on a
WindowsMe playform, using PHP 4.2.3 and Apache/1.3.24 though I'll eventually
migrate the finished code to Linux...

All help appreciated, please, to the newsgroup so that others may learn...
ta,
--



Sun, 29 May 2005 06:50:08 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Index Values of an Array inside a Cluster inside an Array

2. Nested foreach loops

3. nested while loops, inside loop not stopping correctly

4. That nested nested nested if statement...

5. expect: nesting spawn tftp inside spawned telnet

6. foreach with arrays with doubble index?

7. RFC: "array foreach"

8. array foreach

9. Why use the array search commands over foreach?

10. APL2: compress with nested arrays?

11. QUERY ON +.x ON NESTED ARRAYS IN APL2

12. APL Nested Array Questions

 

 
Powered by phpBB® Forum Software