Jump to content

Meaning of this error code


Recommended Posts

I want to create a condition for my script. It starts with reading an array, this array can be unlimited, at least 4 up to 40 elements. These elements contain 2 variables.


I figured out foreach is a better solution than switch (which I use now)


In the next example (simple version of my above purpose) I show what I indicate.

    <?php    $elements = array('Volvo', 'Honda', 'Ford');      ?>       <form method="post">    <select name="menudrop">    <?php foreach ($elements as $value) : ?>                                                                            <option value="<?php echo $value ?>"><?php echo $value ?></option>    <?php endforeach; ?>    </select>    <input type="submit" value="submit" />    </form>    <?php     if (in_array($_POST['menudrop'], $elements)){                                                                echo 'Clients enjoy  eating a ' . $_POST['menudrop'];                                                                   }     ?>   

The problem is an error. The line with the error is:

 if (in_array($_POST['menudrop'], $elements))

what exactly does this error mean?


The script is running and all things are executed like I intended, but I still get an error message at the screen.


Notice: Undefined index:

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...