I created a html form in which you can enter your street address in a single string. How can I extract the street number, street name and street type (crescent, road, street etc) in PHP? I am not sure of the length of the string they will enter and it might not extract the correct information.
Please kindly help as I am new in coding in PHP.
Here is my code below:
$address = $_POST["address"];
echo "Your address is: $address <br>";
$addressSubstring = substr($address,0 , 15);
echo "Address: $addressSubstring <br>";
$strNumber = substr($addressSubstring, 0, 2);
$strName = substr($addressSubstring, 2, 8);
$strType = substr($addressSubstring, 8, 15);
echo "Your street number is: $strNumber <br>";
echo "Your street name is: $strName <br>";
echo "Your street type is: $strType <br>"