co.ador Posted January 8, 2010 Share Posted January 8, 2010 ( [name] => [zipcode] => [state] => [frmSearch] => Array ( [types] => Array ( [0] => ) ) [submit] => Submit ) that's a print_r I have done in one of the index to see how is returning. I believe is false, but i am not completly sure. <?php if ( trim($_POST['name']) == '' && $_POST['zipcode'] =='' && $_POST['state'] =='' && $_POST['frmSearch']['types'] == false ) { echo'no results found'; } else { valid code... } ?> Want to know why going to the else statement when I put <?php && $_POST['frmSearch']['types'] == false?> in the if statement? if it is coming empty then it should echo no results found, because i believe ( [0] => ) is equal false right? Correct me if I am wrong. Thank you.. . Link to comment https://forums.phpfreaks.com/topic/187741-what-is-this-index-equal-to/ Share on other sites More sharing options...
Mchl Posted January 8, 2010 Share Posted January 8, 2010 Check with isset and empty Link to comment https://forums.phpfreaks.com/topic/187741-what-is-this-index-equal-to/#findComment-991192 Share on other sites More sharing options...
co.ador Posted January 8, 2010 Author Share Posted January 8, 2010 some really kind of crazy is happening here. If I use <?php isset($_POST['frmSearch']['types']) ?> Then it will work and echo "no results found" and if I assign a value to types for instance ( [name] => [zipcode] => [state] => [frmSearch] => Array ( [food_types] => Array ( [0] => 5 ) ) [submit] => Submit ) Then it will still echo "no results found" So it means the if statement will return false weather a value is assign or not. Link to comment https://forums.phpfreaks.com/topic/187741-what-is-this-index-equal-to/#findComment-991209 Share on other sites More sharing options...
co.ador Posted January 8, 2010 Author Share Posted January 8, 2010 ["frmSearch"]=> array(1) { ["types"]=> array(1) { [0]=> string(0) "" } } Can anyone please... Tell me what's the value of the index type above? null? false? 0? empty? what? so I can compare in a if statement... I have tried all the possibilities i know of.. Link to comment https://forums.phpfreaks.com/topic/187741-what-is-this-index-equal-to/#findComment-991246 Share on other sites More sharing options...
Mchl Posted January 8, 2010 Share Posted January 8, 2010 It should be empty and also it's strlen should equal 0 Link to comment https://forums.phpfreaks.com/topic/187741-what-is-this-index-equal-to/#findComment-991263 Share on other sites More sharing options...
co.ador Posted January 8, 2010 Author Share Posted January 8, 2010 The test below will work perfectly not until I add another array index <?php <?php if ( trim($_POST['name']) == '' && $_POST['zipcode'] =='' && $_POST['state'] =='' { echo'no results found'; } else { valid code... } ?>?> When i add if ( trim($_POST['name']) == '' && $_POST['zipcode'] =='' && $_POST['state'] =='' && isset($_POST['frmSearch']['types']) ) Then it won't work properly. with the isset it will go into the if statement weather the user enter or not enter an input in the types index? i want it to execute the if statement if user don't enter an input in the types field and if there is an input then to go to the else statement. But right now it will go into the if statement anyways. and if the vaue is empty it should work witht he empty() function but not it won't. Can anybody help me out. I have used all the function I know and it won't pass properly. Link to comment https://forums.phpfreaks.com/topic/187741-what-is-this-index-equal-to/#findComment-991363 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.