tags:

views:

75

answers:

3

Hello,

I wrote a simple foreach to filter one array and write it's results to another array.

foreach ( $users as $user ) {
    ...
    $user_email_list[ ] = $user[ "intranet-id" ][ "value" ];
    ...
}

Problem is that NetBeans is showing me a warning "Variable does not seem to be used in its scope" on $user. If I try to initialize $user before foreach, no warning shows. However it doesn't seem to be right.

Is this a NetBeans bug or do I simply misunderstand anything?

I am using NetBeans version 6.7.1 (Build 200907230233) and PHP 5.2.10.

+1  A: 

Netbeans might be getting it wrong - the code seems ok.

Emil Ivanov
A: 

Code looks fine to me and I have seen Netbeans make similar mistakes before so I wouldn't worry about it.

Interestingly tho, I just copied your code into Netbeans (I am using the exact same version and build) and didn't get a warning

Addsy
Do you have these warnings enabled? Tools->Options->Editor->Hints: check all options.
Ondrej Slinták
A: 

Your code looks fine.. This happens often in NetBeans. Taking one second to look at it and make sure it's wrong is what I usually do. Sometimes closing and re-opening the file makes NetBeans re-parse the file and figure things out. I've also seen re-starting NetBeans do it but that's a pain every time this happens.

Chris Williams