Click here to Skip to main content
15,920,633 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Quote:
when i enter any letter say "ra" "na" etc in the input box it should display all the items which all contain in the salald list, how can i do this ? can any one help me to solve this problem, Below is the code what i have tried with.


What I have tried:

<!DOCTYPE html>

<html>
    
    <body>
        
        <?php
           
            $veggies = array("Potato", "Cucumber", "Carrot", "Orange", "Green Beans", "onion");
            $fruits  = array("Apple", "Banana", "orange", "Pineapple", "Grapes", "Watermelon");
            $salad   = array_merge ($veggies, $fruits);
            $Object = 'ra';
            $search = array_filter($salad, function($list) use ($Object) 
            {
            return ( stripos($list, $Object) !== FALSE );
            });
            print_r($search);
            
        ?>
                <form method="POST">
                    
                Search item:  <input type="text" name="txt" ><br> <br>
                              <input type="submit">
                </form>
            
           
            
    </body>
    
</html>
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900