if (preg_match("/^N/",$postcode)) {
        if (preg_match("/^NW/", $postcode)) {
            if (!preg_match("/^NW1/", $postcode)) {
                // NORTH WEST (NW2, NW3, NW4, NW5, NW6, NW7, NW8, NW9, NW10)
                $property['Prop_area'] = 'NW';
            } else {
                // NW1 which is Central
                $property['Prop_area'] = 'SW';
            }
        } else {
            // NORTH  (N1, N2, N3, N4, N5 etc)
            $property['Prop_area'] = 'N';
        }
    } else if (preg_match("/^W/",$postcode)) {
        if (
            !preg_match("/^W1 /",$postcode)
            && !preg_match("/^W2 /",$postcode)
            && !preg_match("/^W8/",$postcode)
            && !preg_match("/^W11/",$postcode)
        ) {
            // WEST includes (W3, W4, W5, W6, W7, W9, W10, W12, W13, W14)
            $property['Prop_area'] = 'W';
        } else {
            //W1 and W2, W8, W11 which are Central
            $property['Prop_area'] = 'SW';
        }
    } else {
        if (
            preg_match("/^SW/",$postcode)
            || preg_match("/^EC/",$postcode)
            || preg_match("/^WC/",$postcode)
        ) {
            // CENTRAL includes (W1, W2, EC, WC, NW1, SW1, SW3, SW5, SW7, W8, W11)
            $property['Prop_area'] = 'SW';
        } else {
            // OTHER includes South and East and everything else
            return 'SE';
        }
    }
By ichikawayukko, 2018-11-06 12:30:21