Some PHP help please
I'm trying to code a search module that has one input text box, which then searches a database. In the text box the user is asked to enter a town or a uk postcode.
The database does not contain full postcodes, it contains post codes like BD23 1 (the postcode area). My search works fine if I enter a town, or a postcode as it is in the database, but not if I enter a full postcode (BD23 1AA). I need to strip off the AA (last two characters if they are non numeric.
I have this code:
/*IF THERES A DIGIT IN KEYWORD ASSUME POSTCODE*/
if (preg_match('/[^0-9A-Za-z]+$/',$keyword)) {
//SEE IF LAST 2 CHARS ARE LETTERS
$last3chars = substr($keyword, -2);
if (!is_int(substr($last3chars, -2))) {
$keyword = substr($keyword,0,-2);
}
} Thanks in advance.
Generate thousands of leads in any niche in under 60 seconds!
Generate thousands of leads in any niche in under 60 seconds!