Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to use in_array in php to find value in a array list?

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 213
    Comment on it

    You can take reference form below example to find the value in an array list using php in_array.

    Suppose you have a list of Favorite List items (for example a list of colors names) and you want search your color is exist in list or not exist.

                    <?php
                        $GetColors = array("Green", "Red", "Blue", "Yellow","Pink");
                        /*$GetColors is a userdefine variable in which store all colors name.*/
    
                        /*Now suppose you want search blue colors in array list.*/
    
                        //put this query
                        if (in_array("Blue", $GetColors))
                          {
                          echo "success colors Found";
                          }
                        else
                          {
                          echo "fail colors Not Found";
                          }
                    ?>
    

    If Blue color exist in given array list then result will come "success colors Found";

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: