It's definitely possible to do when you do it in PHP, but not sure about on
the database side. You could read all records into memory and then iterate
over it with something like:

$toSearch = "4D24487PS"
$charsToIgnore = array('-','+',...);

foreach ($items as $k=>$item) {
  $itemVal = str_replace($charsToIgnore, '', $item);
  if (strcmp(str_replace($charsToIgnore, '', $toSearch), $itemVal) == 0) {
    $return = $item;

This however might use a lot of memory, but if your DB is a manageable size
it should be ok. You can probably optimise it by iterating over a db result
set instead of reading everything into an array.

++Tim Hinnerk Heuer++


2009/9/3 <sono...@fannullone.us>

>        Is there is a way to search only for the alphanumeric content of
> field in a db?  I have an itemID field that contains item #'s that include
> dashes, forward slashes, etc, and I want people to be able to search for an
> item # even if they don't enter the punctuation exactly.
>        Here's an example:  let's say there is an itemID of 4D-2448-7PS but
> someone omits the dashes and searches on 4D24487PS.  Is it possible in PHP
> to have the find be successful, even if the search criteria doesn't exactly
> match what's stored in the field?
>        If this is possible, I'd appreciate it if someone could just point
> me in the right direction so I can read up on it.
> Thanks,
> Frank
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to