physaux Posted October 15, 2009 Share Posted October 15, 2009 Relevant Code: <?php foreach( $Data as $index => $arraydata){ foreach( $Data[$index] as $index2 => $arraydata2){ foreach( $Data[$index] as $index3 => $arraydata3){ if($index3!=$index2 { if ($Data[$index][index2]["Name"] == $Data[$index][index3]["Name"]){ //THIS IS PROBLEM LINE echo "same name!"; } } } } //... ?> I get the following error for that part of code: Notice: Use of undefined constant index2 - assumed 'index2' in /Users.../ Anybody can tell me what is going on? Can i not use the "as ______" variablie within the statement? Quote Link to comment Share on other sites More sharing options...
mrMarcus Posted October 15, 2009 Share Posted October 15, 2009 missing a closing ) on this line... if($index3!=$index2 { Quote Link to comment Share on other sites More sharing options...
taquitosensei Posted October 15, 2009 Share Posted October 15, 2009 your forgot the $ in front of index2 and 3 if it is an key then it should be surround by single quotes. if ($Data[$index][$index2]['Name'] == $Data[$index][$index3]['Name']){ //THIS IS PROBLEM LINE Quote Link to comment Share on other sites More sharing options...
ialsoagree Posted October 15, 2009 Share Posted October 15, 2009 "index2" and "index3" is not defined as a variable, see correction below: <?php foreach( $Data as $index => $arraydata){ foreach( $Data[$index] as $index2 => $arraydata2){ foreach( $Data[$index] as $index3 => $arraydata3){ if($index3!=$index2) { if ($Data[$index][$index2]["Name"] == $Data[$index][$index3]["Name"]){ //THIS IS PROBLEM LINE echo "same name!"; } } } } //... ?> By the way, this also works (if you didn't realize you're creating multiple arrays): <?php foreach( $Data as $index => $arraydata){ foreach( $arraydata as $index2 => $arraydata2){ foreach( $arraydata2 as $index3 => $arraydata3){ if($index3!=$index2) { if ($Data[$index][$index2]["Name"] == $Data[$index][$index3]["Name"]){ //THIS IS PROBLEM LINE echo "same name!"; } } } } //... ?> Quote Link to comment Share on other sites More sharing options...
physaux Posted October 15, 2009 Author Share Posted October 15, 2009 ok got it working, thanks!! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.