?

Search Help Board

PHP FAQ
PHP Articles
PHP Help
Bulletin Board

PHP Manual (NEW!)
First Time PHP'ers
Help with programming
Sql assignment help
PHP Homework Help


?
?Re: searching help !!
Author:??(---.scpe.powergate.ca)
Date:???07-29-04 11:53

Oh, you're gonna love this:

Not sure if you are simply checking to see if its present in the array, in which case in_array() is the function to use...

$search_car = "volvo";

if (!in_array($search_car, $car_manu)){
$msg = "car not in database";
}else{
//process search with sql


}

if you need to get the actual key of the index, then PHP has a function called array_flip, which transposes the key and values...so.......

$search_car = "volvo";

$flip_car_manu = array_change_key_case (array_flip($car_manu), CASE_LOWER); //to simplify comparisons since Volvo != volvo

$mykey = $flip_car_manu[$search_car];

//process search with sql

?Topics Author? Date
?searching help !!??new
Moses 07-26-04 20:47?
?Re: searching help !!??new
bastien 07-27-04 12:15?
?Re: searching help !!??new
Moses 07-28-04 10:50?
?Re: searching help !!??new
bastien 07-28-04 11:38?
?Re: searching help !!??new
Moses 07-29-04 09:59?
?Re: searching help !!??new
bastien 07-29-04 11:53?
?Re: searching help !!??new
Moses 07-30-04 14:27?
Go to Top??|??Go to Topic??|??Flat View??|??Search?
??|??
New Topic
?Reply To This Message
?Your Name:
?Your Email:
?Subject:
Email replies to this thread, to the address above.
??wrote: > > Oh, you're gonna love this: > > Not sure if you are simply checking to see if its present in > the array, in which case in_array() is the function to use... > > $search_car = "volvo"; > > if (!in_array($search_car, $car_manu)){ > $msg = "car not in database"; > }else{ > //process search with sql > > > } > > if you need to get the actual key of the index, then PHP has > a function called array_flip, which transposes the key and > values...so....... > > $search_car = "volvo"; > > $flip_car_manu = array_change_key_case > (array_flip($car_manu), CASE_LOWER); //to simplify > comparisons since Volvo != volvo > > $mykey = $flip_car_manu[$search_car]; > > //process search with sql ">??

Provided By
Phorum