使用PHP删除字符串的字符

Im trying to show local shops in a area the user types in a post code it then grabs shops from the database and displays them so i need it so when a user types in a post code like so

mp1234

it will just keep the mp1 in my database there is a covered table were the stores add post codes to show they cover this area so they add the start of each post code like so mp1 to say they cover that area. The user will be entering the full post code so just need the first 3 char.

Thank you

You should use the substr built-in PHP function: http://php.net/manual/en/function.substr.php

This function will allow you to get substrings from a given string. For example:

$postcode = 'GU14LG';
$region = substr($postcode, 0, 3); // This is now GU1