I have the following PHP code:-
<?php
if( have_rows('postcode_checker', 'option') ):
while ( have_rows('postcode_checker', 'option') ) : the_row(); ?>
<?php
$postcodes .= get_sub_field('postcodes');
$postcode_url = get_sub_field('page');
?>
<?php endwhile;
else : endif;
$postcode_array = $postcodes; // This collects postcodes, i.e. LE67, LE5 etc...
$postcode_array = explode(',', $postcode_array);
$postcode_array = str_replace(' ', '', $postcode_array);
$postcode_search = $_POST['postcode']; // This will be a single postcode i.e. LE67
if (in_array($postcode_search, $postcode_array)) {
echo 'yes';
} else {
echo 'no';
}
?>
So the code above is working fine if I want to look up say LE67 and it finds LE67 in the array and returns 'yes'
. Now if I search LE675AN for example it will return no
even though it needs to be returning yes as it is within the postcode area.
Any idea's on how I can achieve this?