Jump to content

what is this index equal to?


co.ador

Recommended Posts

 

 

(

    [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

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.

 

 

["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..

 

 

 

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.