ahs10 Posted February 15, 2008 Share Posted February 15, 2008 i am updating some code and would like to know the logic behind my new code is correct. here's my old code.... if (($data->sheets[0]['numCols'] > 9) || ($data->sheets[0]['cells'][1][1] != "ID") || ($data->sheets[0]['cells'][1][2] != "Date Submitted") || ($data->sheets[0]['cells'][1][3] != "Group") || ($data->sheets[0]['cells'][1][4] != "Comments")) { //do this } now i want to introduce a condition to those conditions, that depends on $userType. it introduces $colCount to the logic, which i know will work fine, but i'm questioning the last line before the first curly brace.... if (($data->sheets[0]['numCols'] > $colCount) || ($data->sheets[0]['cells'][1][1] != "ID") || ($data->sheets[0]['cells'][1][2] != "Date Submitted") || ($data->sheets[0]['cells'][1][3] != "Group") || ($data->sheets[0]['cells'][1][4] != "Comments")) || (($data->sheets[0]['cells'][1][5] == "RVL") && ($userType == "Buda")) { //do this } i only want it to look for the RVL cell if the $userType is Buda. i always want it to check the original conditions though, regardless. is this correct? Link to comment https://forums.phpfreaks.com/topic/91306-will-someone-verify-this-logic-please/ Share on other sites More sharing options...
craygo Posted February 15, 2008 Share Posted February 15, 2008 I would think it would be like this if ( ($data->sheets[0]['numCols'] > $colCount || $data->sheets[0]['cells'][1][1] != "ID" || $data->sheets[0]['cells'][1][2] != "Date Submitted" || $data->sheets[0]['cells'][1][3] != "Group" || $data->sheets[0]['cells'][1][4] != "Comments") && ($data->sheets[0]['cells'][1][5] == "RVL" && $userType == "Buda") ) { //do this } Ray Link to comment https://forums.phpfreaks.com/topic/91306-will-someone-verify-this-logic-please/#findComment-467931 Share on other sites More sharing options...
ahs10 Posted February 15, 2008 Author Share Posted February 15, 2008 that's exactly where i got confused..... i should have stayed in school long enough to take at least one logic class... uggg. so basically i have two condition sets, one that always needs to be checked and one that only needs to be checked if userType == Buda. so you're saying that i need to say (condition set 1-always) && (condition set 2-sometimes), rather than (condition set 1-always) || (condition set 2-sometimes)? now that i think about it, are you sure? why would it be AND, not OR? if cond1 AND cond2 == true.... but what if cond2 is false, i still want cond1 to execute if it's true... so it would be OR. sorry, i'm thinking in my post. thanks for sparking this thought, but i think my original was correct. thanks again! Link to comment https://forums.phpfreaks.com/topic/91306-will-someone-verify-this-logic-please/#findComment-467943 Share on other sites More sharing options...
craygo Posted February 15, 2008 Share Posted February 15, 2008 You are right my bad. I read what you wanted wrong you may have to check the buda first if ($userType == "Buda"){ if( $data->sheets[0]['numCols'] > $colCount || $data->sheets[0]['cells'][1][1] != "ID" || $data->sheets[0]['cells'][1][2] != "Date Submitted" || $data->sheets[0]['cells'][1][3] != "Group" || $data->sheets[0]['cells'][1][4] != "Comments" || $data->sheets[0]['cells'][1][5] == "RVL"){ // do this } } else { if( $data->sheets[0]['numCols'] > $colCount || $data->sheets[0]['cells'][1][1] != "ID" || $data->sheets[0]['cells'][1][2] != "Date Submitted" || $data->sheets[0]['cells'][1][3] != "Group" || $data->sheets[0]['cells'][1][4] != "Comments"){ // do this } } Ray Link to comment https://forums.phpfreaks.com/topic/91306-will-someone-verify-this-logic-please/#findComment-467949 Share on other sites More sharing options...
ahs10 Posted February 15, 2008 Author Share Posted February 15, 2008 cool, thanks again though, really. in trying to convey my ideas to you, i learned a lot. have a great weekend. Link to comment https://forums.phpfreaks.com/topic/91306-will-someone-verify-this-logic-please/#findComment-467965 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.