Hi there I want to separate the first part of the postcode (up to the space) from the rest. Please bear in mind that first part of a postcode can be 3 or 4 characters long. I have written this php code, which is wrong. $code=$_POST["pcode"]; $data= ( preg_match('/^[a-zA-Z0-9]+[[$:space:]]/', $code) ); echo $data; Code (markup): can some one please help. thx in advance.
If there is definitely doing to be a space, why not just use explode? $code = $_POST["pcode"]; $data = explode(' ', $code); print_r($data); PHP: Sorry if I've missed the point Jay
Hi No you haven't missed the point and in theory should have solved the problem but I get this message when I enter the postcode FD5 2DE: Array ( [0] => FG5 [1] => 2DE any ideas please? thx
That's just outputting the array. This should guide you: echo "First part: "; echo $data[0]; echo "First second: "; echo $data[1]; PHP:
Hi Got it. I used: echo $data[0]; Code (markup): That gave me the first part of the code up to space. many thx