bonjour a tous...
voila, donc je cherche a faire fusionner 2 codes que j'ai fait mais
je voi pas pour le moment la solution... je pense que c'est simple
mais je bloque


pour expliquer :
les codes sont pour réaliser un moteur de recherche interne de petite
annonces.
- Le 1 code est pour la receheche de "ville,CP,Département".
- Le 2 code pour faire une recherche de CP, exemple on tape
32200 et sa va cherche entre 100ou ou autre de plus ou moin.
(de 32100 à 32300).

Le bute :
le bute de la fusion est de pouvoir détecter les CP du 1 code
pour leur apliquer la recherche du 2 code. puis faire la recherche..

1 code :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
 
$informations = strtolower(@$_GET['informations']);
$informations = str_replace(", ", " ", trim($informations)); 
$informations = str_replace(",", " ", $informations); 
$informations = str_replace("; ", " ", $informations);
$informations = str_replace(";", " ", $informations);
$informations = str_replace("+", " ", $informations); 
$informations = str_replace("\"", " ", $informations);
$informations = str_replace(":", " ", $informations);
$tab=explode(" " , $informations);
 
 if ($tab[0] != '' || $tab[1] != '' || $tab[2] != '' || $tab[3] != '' || $tab[4] != '')
{ 
 $query_search .= "
AND ((products.departement = '$tab[0]') OR (products.ville = '$tab[0]') OR (products.codepostal = '$tab[0]')
OR (products.departement = '$tab[1]') OR (products.ville = '$tab[1]') OR (products.codepostal = '$tab[1]')
OR (products.departement = '$tab[2]') OR (products.ville = '$tab[2]') OR (products.codepostal = '$tab[2]')
OR (products.departement = '$tab[3]') OR (products.ville = '$tab[3]') OR (products.codepostal = '$tab[3]')
OR (products.departement = '$tab[4]') OR (products.ville = '$tab[4]') OR (products.codepostal = '$tab[4]'))";
}
2 code :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
 
$val =trim(@$_GET['codepostal']); 
$fourchette =trim(@$_GET['distance']); 
if($val == '') { 
   $val_mini = "00000"; 
   $val_maxi = "99999"; 
   $query_search .= " AND products.codepostal BETWEEN ". $val_mini ." AND ". $val_maxi; 
}elseif($fourchette == '') { 
   $val = intval($val); 
   if ($val < 0) $val = -$val; 
   $query_search .= " AND products.codepostal = ".$val;
}else { 
   $fourchette = intval(substr($fourchette,0,3)); 
   $val = intval($val); 
   if ($val < 0) $val = -$val; 
   $departm = intval($val/1000); 
   $departm_mini = 1000*$departm; 
   $departm_maxi = $departm_mini + 999; 
   $val_mini = $val-$fourchette; 
   $val_maxi = $val+$fourchette; 
   if ($val_mini < $departm_mini) $val_mini = $departm_mini; 
   if ($val_maxi > $departm_maxi) $val_maxi = $departm_maxi; 
   $query_search .= " AND products.codepostal BETWEEN ". $val_mini ." AND ". $val_maxi; 
}

en faite je c'est pas comment faire pour trouver les codes a 5 chiffres pour les tréter...
Je reste ouvert a toutes remarques ou indices

je pense a un truc...

en faite il me faut juste savoir ci ($tab[0] ou $tab[1]...) son bien
des chiffres a 5 chiffres puis je les donnes au 2 code.


du style :

If ($tab[0] != ???) {
2 code }

If ($tab[1] != ???) {
2 code }

Ma question est :
comment faire cette vérification ???

j'ai testé avec :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
 
if( ! preg_match( '/[0-9]{5}$/', $tab[0] ) ){	
 
2 code
 
}
Mais sa ne marche pas