Welcome Guest, Not a member yet? Register   Sign In
Case insensitive needle in haystack
#1

[eluser]whiteae[/eluser]
So I'm trying to get the session variable to be the default value in my dropdown list. It works unless the user types it all lowercase in which the data is not. So if a user types in k&n, it doesn't recognize it in the array because the data in the array is K&N. What is the easiest way to accomplish this?

Here is the code I have now..
Code:
<?php echo form_open('items/index'); ?>
                    <?php echo form_label('Brand:', 'brand-name'); ?>
                    <?php $session_var = urldecode($this->session->userdata('brandLabel')); ?>
                    <?php foreach ($brandName as $brand): ?>
                        <?php

                            foreach($brand as $name)
                            {
                                $options[]= $name;                                
                            }//end foreach
                        ?>

                    <?php endforeach ?>
                       <?php echo $session_var;
                       ?>
                    <?php echo form_dropdown('brandLabel', $options, $session_var);?>

                    <?php echo form_label('Search for part number:', 'search-box'); ?>
                    <?php echo form_input(array('name' => 'q',
                            'id' => 'search-box',
                            'size' => '25',
                            'value' => $this->session->userdata('partNum'))); ?>
                    <?php echo form_submit('search', 'Search'); ?>
                    <?php echo form_close(); ?>
#2

[eluser]DarkManX[/eluser]
http://www.php.net/manual/en/function.strtolower.php
#3

[eluser]whiteae[/eluser]
I tried using that and I couldn't get it to work for some reason. I know to compare them by that, but can't figure out if the lower case item is in the lower case array item.
#4

[eluser]DarkManX[/eluser]
dont get where you compare them. you just post the form. post the code which campares the input-stuff.
#5

[eluser]whiteae[/eluser]
This doesn't help me much at all..
#6

[eluser]whiteae[/eluser]
Sad(((




Theme © iAndrew 2016 - Forum software by © MyBB