{"id":22887,"date":"2024-08-30T12:01:03","date_gmt":"2024-08-30T10:01:03","guid":{"rendered":"https:\/\/www.geopostcodes.com\/en-GB\/?p=22887"},"modified":"2026-04-01T07:01:01","modified_gmt":"2026-04-01T07:01:01","slug":"php-street-address-validation","status":"publish","type":"post","link":"https:\/\/www.geopostcodes.com\/en-GB\/blog\/php-street-address-validation\/","title":{"rendered":"PHP Street Address Validation"},"content":{"rendered":"\n<p>Street <a href=\"https:\/\/www.geopostcodes.com\/en-GB\/address-validation-service\/\">address validation<\/a> involves verifying the accuracy and completeness of addresses provided by users to ensure the addresses exist and are correctly formatted according to postal standards. This process helps businesses reduce errors related to incomplete or incorrect addresses, such as late or unsuccessful deliveries or sending out irrelevant information to clients based on their location, which can incur costs or damage a business&#8217;s reputation.<\/p>\n\n\n\n<p class=\"has-background\" style=\"background-color:#d7efff\">\ud83c\udf0e Want to eliminate <a href=\"https:\/\/www.geopostcodes.com\/en-GB\/international-address-verification\/\">international address validation<\/a> errors? Access our enterprise postal postcode database with international address formats. Precise, accurate, and up-to-date.&nbsp;<a href=\"https:\/\/public.geopostcodes.com\/portal-signup\" target=\"_blank\" rel=\"noreferrer noopener\"><strong>Browse GeoPostcodes database for free.<\/strong><\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/www.geopostcodes.com\/en-GB\/address-validation-service\/\">Address validation<\/a> improves data accuracy, enhances user experience, and ensures timely deliveries and communications. For instance, CRM systems help ensure that the customer information provided is accurate, which helps facilitate better communication. In e-commerce, it helps minimize shipping errors and enhances overall customer satisfaction by ensuring that products ordered reach the correct destination. Logistics companies rely on accurate <a href=\"https:\/\/www.geopostcodes.com\/en-GB\/address-validation-service\/\">address validation<\/a> to optimize route planning and reduce operational costs.<\/p>\n\n\n\n<p>In this article, you&#8217;ll learn how to use the street data provided by <a href=\"https:\/\/www.geopostcodes.com\/en-GB\" target=\"_blank\" rel=\"noreferrer noopener\">GeoPostcodes<\/a> to create a robust <a href=\"https:\/\/www.geopostcodes.com\/en-GB\/address-validation-service\/\">address validation<\/a> system in Laravel, a PHP web framework.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Prerequisites<\/h2>\n\n\n\n<p>To follow along with this tutorial, make sure you have the following:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>A <a href=\"https:\/\/portal.geopostcodes.com\/\" target=\"_blank\" rel=\"noreferrer noopener\">GeoPostcodes account<\/a><\/li>\n<\/ul>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/www.php.net\/downloads.php\" target=\"_blank\" rel=\"noreferrer noopener\">PHP<\/a> and <a href=\"https:\/\/getcomposer.org\/\" target=\"_blank\" rel=\"noreferrer noopener\">Composer<\/a> installed on your local machine<\/li>\n<\/ul>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/nodejs.org\/\" target=\"_blank\" rel=\"noreferrer noopener\">Node.js and npm<\/a> installed on your local machine<\/li>\n<\/ul>\n\n\n\n<ul class=\"wp-block-list\">\n<li>A code editor and a web browser. This guide uses <a href=\"https:\/\/code.visualstudio.com\/download\" target=\"_blank\" rel=\"noreferrer noopener\">VS Code<\/a> and <a href=\"https:\/\/www.mozilla.org\/en-US\/firefox\/new\/\" target=\"_blank\" rel=\"noreferrer noopener\">Firefox Browser<\/a>.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Obtaining Street Data from GeoPostcodes<\/h2>\n\n\n\n<p>First, you need to obtain street data from GeoPostcodes to use in your PHP application.<\/p>\n\n\n\n<p>Log in to the <a href=\"https:\/\/portal.geopostcodes.com\/\" target=\"_blank\" rel=\"noreferrer noopener\">GeoPostcodes portal<\/a> and select <strong>Download Center<\/strong>.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-large\"><img fetchpriority=\"high\" decoding=\"async\" width=\"1024\" height=\"705\" src=\"https:\/\/www.geopostcodes.com\/en-GB\/wp-content\/uploads\/2024\/08\/dwiVE8q-1024x705.webp\" alt=\"php street address validation\" class=\"wp-image-22908\" srcset=\"https:\/\/www.geopostcodes.com\/en-GB\/wp-content\/uploads\/2024\/08\/dwiVE8q-1024x705.webp 1024w, https:\/\/www.geopostcodes.com\/en-GB\/wp-content\/uploads\/2024\/08\/dwiVE8q-300x207.webp 300w, https:\/\/www.geopostcodes.com\/en-GB\/wp-content\/uploads\/2024\/08\/dwiVE8q-768x529.webp 768w, https:\/\/www.geopostcodes.com\/en-GB\/wp-content\/uploads\/2024\/08\/dwiVE8q.webp 1433w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<div style=\"height:40px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>On the <strong>Download Center<\/strong> page, under <strong>Samples<\/strong>, select <strong>Street database<\/strong>.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-large\"><img decoding=\"async\" width=\"1024\" height=\"607\" src=\"https:\/\/www.geopostcodes.com\/en-GB\/wp-content\/uploads\/2024\/08\/CHC942M-1024x607.webp\" alt=\"php street address validation\" class=\"wp-image-22910\" srcset=\"https:\/\/www.geopostcodes.com\/en-GB\/wp-content\/uploads\/2024\/08\/CHC942M-1024x607.webp 1024w, https:\/\/www.geopostcodes.com\/en-GB\/wp-content\/uploads\/2024\/08\/CHC942M-300x178.webp 300w, https:\/\/www.geopostcodes.com\/en-GB\/wp-content\/uploads\/2024\/08\/CHC942M-768x455.webp 768w, https:\/\/www.geopostcodes.com\/en-GB\/wp-content\/uploads\/2024\/08\/CHC942M-1536x910.webp 1536w, https:\/\/www.geopostcodes.com\/en-GB\/wp-content\/uploads\/2024\/08\/CHC942M.webp 1674w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<div style=\"height:40px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>On the <strong>Street database<\/strong> page, under <strong>Packages<\/strong>, choose <strong>North America, sample countries<\/strong>.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-large\"><img decoding=\"async\" width=\"1024\" height=\"607\" src=\"https:\/\/www.geopostcodes.com\/en-GB\/wp-content\/uploads\/2024\/08\/pXwuC4k-1024x607.webp\" alt=\"php street address validation\" class=\"wp-image-22911\" srcset=\"https:\/\/www.geopostcodes.com\/en-GB\/wp-content\/uploads\/2024\/08\/pXwuC4k-1024x607.webp 1024w, https:\/\/www.geopostcodes.com\/en-GB\/wp-content\/uploads\/2024\/08\/pXwuC4k-300x178.webp 300w, https:\/\/www.geopostcodes.com\/en-GB\/wp-content\/uploads\/2024\/08\/pXwuC4k-768x455.webp 768w, https:\/\/www.geopostcodes.com\/en-GB\/wp-content\/uploads\/2024\/08\/pXwuC4k-1536x910.webp 1536w, https:\/\/www.geopostcodes.com\/en-GB\/wp-content\/uploads\/2024\/08\/pXwuC4k.webp 1676w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<div style=\"height:40px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>GeoPostcodes offers comprehensive international address databases, but this tutorial only uses US data for the sake of simplicity.<\/p>\n<\/blockquote>\n\n\n\n<p>On the <strong>Download<\/strong> page, you&#8217;ll find the description of the data you have selected and the file format. Click the <strong>Download<\/strong> button, read the license restriction information displayed, and download the data.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"582\" src=\"https:\/\/www.geopostcodes.com\/en-GB\/wp-content\/uploads\/2024\/08\/GMUlj61-1024x582.webp\" alt=\"php street address validation\" class=\"wp-image-22912\" srcset=\"https:\/\/www.geopostcodes.com\/en-GB\/wp-content\/uploads\/2024\/08\/GMUlj61-1024x582.webp 1024w, https:\/\/www.geopostcodes.com\/en-GB\/wp-content\/uploads\/2024\/08\/GMUlj61-300x170.webp 300w, https:\/\/www.geopostcodes.com\/en-GB\/wp-content\/uploads\/2024\/08\/GMUlj61-768x436.webp 768w, https:\/\/www.geopostcodes.com\/en-GB\/wp-content\/uploads\/2024\/08\/GMUlj61-1536x873.webp 1536w, https:\/\/www.geopostcodes.com\/en-GB\/wp-content\/uploads\/2024\/08\/GMUlj61.webp 1751w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<div style=\"height:40px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>The street data will be downloaded to your local machine as a zipped file. Unzip the file and take note of the file named <strong>GPC-STRT-GEO-SAMPLE-A1-SELECTED.csv<\/strong> under the path <code>&lt;EXTRACTED-FOLDER-NAME&gt;\/CSV<\/code>. This file contains all the data you need to create the street <a href=\"https:\/\/www.geopostcodes.com\/en-GB\/address-validation-service\/\">address validation<\/a> system. You will use this file later.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Creating a Laravel Application<\/h2>\n\n\n\n<p>Next, you&#8217;ll create a Laravel application that will make use of the data you just obtained. The Laravel application will have a user interface that captures the relevant data from the user\u2014street, city, state, and postal code\u2014and a controller that validates whether the information provided is a valid address by checking it against data stored in the database. If the address provided is valid, the user interface will show a success message. If not, it will display an error message.<\/p>\n\n\n\n<p>Create a Laravel application by executing the command below in your terminal:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"php\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">composer create-project laravel\/laravel street-address-validation<\/pre>\n\n\n\n<p><em>Note:<\/em> This tutorial&#8217;s workflow is based on Laravel 11.<\/p>\n\n\n\n<p>You will first implement the backend logic and then implement the user interface later.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Implementing the Backend Logic<\/h3>\n\n\n\n<p>You now need to create a database table and populate it with the CSV data you obtained in the previous step, which involves a couple of steps.<\/p>\n\n\n\n<p>First, copy the CSV file you obtained in the previous step in the project root folder and open the file in the IDE. You&#8217;ll notice that the CSV file has several columns, but this tutorial only uses a few: <code>street<\/code>, <code>locality<\/code> (will represent <code>city<\/code>), <code>region1<\/code> (will represent <code>state<\/code>), and <code>postcode<\/code>.<\/p>\n\n\n\n<p>Next, <code>cd<\/code> into the project root directory and create a database table for storing the street data by executing the command below in your terminal.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"php\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">cd street-address-validation\n\nphp artisan make:migration create_street_address_table<\/pre>\n\n\n\n<p>This command creates a new migration in the <code>database\/migrations<\/code> folder. Open the file and replace the <code>up<\/code> method with the code below:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"php\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">public function up(): void\n{\n    Schema::create('street_address', function (Blueprint $table) {\n        $table-&gt;id();\n        $table-&gt;timestamps();\n        $table-&gt;string('street');\n        $table-&gt;string('city');\n        $table-&gt;string('state');\n        $table-&gt;string('zip_code');\n    });\n}<\/pre>\n\n\n\n<p>The <code>up<\/code> method uses the <code>Schema::create<\/code> function to specify the structure of the table. It includes an auto-incrementing primary key (<code>id<\/code>), timestamp columns (<code>created_at<\/code> and <code>updated_at<\/code>), and string columns for <code>street<\/code>, <code>city<\/code>, <code>state<\/code>, and <code>zip_code<\/code>. This sets up the necessary schema to store street address information in the database.<\/p>\n\n\n\n<p>Next, run the migration with this command:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"php\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">php artisan migrate<\/pre>\n\n\n\n<p>Then, create a model to interact with the database by executing the command below.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"php\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">php artisan make:model StreetAddress<\/pre>\n\n\n\n<p>The command creates a model in the <code>app\/Models<\/code> folder. Open the model and add the following code below the <code>use HasFactory;<\/code> statement to specify the table name and the mass-assignable fields:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"php\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/\/ Specify the table name\nprotected $table = 'street_address';\n\n\/\/ Specify the mass-assignable fields\nprotected $fillable = [\n    'street',\n    'city',\n    'state',\n    'zip_code',\n];<\/pre>\n\n\n\n<p>With the database table and the model ready, you can now use the CSV file you copied to the project root folder to seed the database. Execute the command below to create a database seeder:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"php\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">php artisan make:seeder StreetAddressSeeder<\/pre>\n\n\n\n<p>The command creates the seeder in the <code>database\/seeders<\/code> directory.<\/p>\n\n\n\n<p>Open the seeder you created and add the following code inside the <code>run<\/code> method:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"php\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/\/ Truncate the table to remove existing data\nStreetAddress::truncate();\n\n\/\/ CSV file path\n$csvFile = fopen(base_path('GPC-STRT-GEO-SAMPLE-A1-SELECTED.csv'), 'r');\n\n\/\/ Check if the file is opened successfully\nif ($csvFile === false) {\n    die('Error opening the CSV file.');\n}\n\n\/\/ Skip the first row (the header)\nfgetcsv($csvFile, 1000, ',');\n\n\/\/ Define the columns to extract and their positions\n$columnsToExtract = [\n    'street' =&gt; 11,\n    'locality' =&gt; 8,\n    'region1' =&gt; 4,\n    'postcode' =&gt; 9\n];\n\n\/\/ Loop through all the rows and insert the data into the DB\nwhile (($row = fgetcsv($csvFile, 1000, ';')) !== false) {\n    \/\/ Extract the specified columns\n    $extractedData = [];\n    foreach ($columnsToExtract as $column =&gt; $index) {\n        if (isset($row[$index])) {\n            $extractedData[$column] = $row[$index];\n        } else {\n            $extractedData[$column] = ''; \/\/ Handle missing data\n        }\n    }\n\n    StreetAddress::create([\n        'street' =&gt; $extractedData['street'],\n        'city' =&gt; $extractedData['locality'],\n        'state' =&gt; $extractedData['region1'],\n        'zip_code' =&gt; $extractedData['postcode'],\n    ]);\n}\n\n\/\/ Close the file\nfclose($csvFile);<\/pre>\n\n\n\n<p>This code first truncates the database table to remove any existing data. Then, it opens the specified CSV file for reading and skips the header row. It defines specific columns to extract from the CSV with their respective positions. As it loops through each row of the CSV, it extracts the necessary columns, handling any missing data by assigning an empty string. It then uses the <code>StreetAddress<\/code> model to insert the extracted data into the appropriate database table. Finally, the CSV file is closed.<\/p>\n\n\n\n<p>Make sure you import the <code>StreetAddress<\/code> model into the current namespace:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"php\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">use App\\Models\\StreetAddress;<\/pre>\n\n\n\n<p>Next, run the seeder using the command below:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"php\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">php artisan db:seed --class=StreetAddressSeeder<\/pre>\n\n\n\n<p>This command executes the <code>StreetAddressSeeder<\/code> class and populates the appropriate database table with data extracted from the CSV file.<\/p>\n\n\n\n<p>Next, you&#8217;ll create a controller to handle user requests. The controller will check whether the provided user address exists in the database and return the appropriate response.<\/p>\n\n\n\n<p>To create the controller, execute the command below in your terminal:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"php\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">php artisan make:controller StreetAddressController<\/pre>\n\n\n\n<p>The command creates the controller in the <code>app\/Http\/Controllers<\/code> directory. Open the file and add the following code to the <code>StreetAddressController<\/code> Class:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"php\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">public function create()\n{\n    return view('street_address.create');\n}\n\npublic function validate(Request $request)\n{\n    \/\/ Validate the incoming data\n    $request-&gt;validate([\n        'street' =&gt; 'required|string',\n        'city' =&gt; 'required|string',\n        'state' =&gt; 'required|string',\n        'zip_code' =&gt; 'required|string',\n    ], [\n        'street.required' =&gt; 'Street field is required.',\n        'city.required' =&gt; 'City field is required.',\n        'state.required' =&gt; 'State field is required.',\n        'zip_code.required' =&gt; 'Postcode field is required.',\n    ]);\n\n    \/\/ Retrieve inputs\n    $street = $request-&gt;input('street');\n    $city = $request-&gt;input('city');\n    $state = $request-&gt;input('state');\n    $zipCode = $request-&gt;input('zip_code');\n\n    \/\/ Check if the provided address exists in DB\n    $addressExists = StreetAddress::whereRaw('LOWER(street) = ?', [strtolower($street)])\n            -&gt;whereRaw('LOWER(city) = ?', [strtolower($city)])\n            -&gt;whereRaw('LOWER(state) = ?', [strtolower($state)])\n            -&gt;whereRaw('LOWER(zip_code) = ?', [strtolower($zipCode)])\n      -&gt;exists();\n\n    \/\/ Return the appropriate response\n    if ($addressExists) {\n        return back()-&gt;with('success', 'Address is valid.');\n    } else {\n        return back()-&gt;withErrors(['message' =&gt; 'Address does not exist. Please check your input.'])-&gt;withInput();\n    }\n}<\/pre>\n\n\n\n<p>The <code>create<\/code> method returns a view that displays a form for entering a new address. You will create this form later. The <code>validate<\/code> method checks if the address data the user provided is correct. It enforces that <code>street<\/code>, <code>city<\/code>, <code>state<\/code>, and <code>zip_code<\/code> fields are required and must be strings. If validation fails, custom error messages are shown. If the validation succeeds, the code retrieves the input data and checks if an address with the same details exists in the database. If the address exists, it returns a success message. Otherwise, it returns an error message and the input data to the form.<\/p>\n\n\n\n<p>Make sure you import the <code>StreetAddress<\/code> model into the current namespace:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"php\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">use App\\Models\\StreetAddress;<\/pre>\n\n\n\n<p>Lastly, set up routing for the application by replacing the code in the <strong>routes\/web.php<\/strong> file with the following:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"php\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;?php\n\nuse App\\Http\\Controllers\\StreetAddressController;\nuse Illuminate\\Support\\Facades\\Route;\n\nRoute::get('\/', [StreetAddressController::class, 'create']);\nRoute::post('\/', [StreetAddressController::class, 'validate'])-&gt;name('validate.address');<\/pre>\n\n\n\n<p>Your backend logic is now complete.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Implementing the User Interface<\/h3>\n\n\n\n<p>Your user interface will be an HTML form where the end user can input an address and submit it to the backend for validation.<\/p>\n\n\n\n<p>Create a new file named <strong>street_address\/create.blade.php<\/strong> in the <code>resources\/views<\/code> folder and add the code below:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"php\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\n\n    \n        <meta charset=\"UTF-8\">\n        <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n        <title>Street &lt;a href=\"https:\/\/www.geopostcodes.com\/en-GB\/address-validation-service\/\"&gt;Address Validation&lt;\/a&gt;<\/title>\n        <link href=\"https:\/\/cdn.jsdelivr.net\/npm\/bootstrap@5.2.3\/dist\/css\/bootstrap.min.css\" rel=\"stylesheet\" integrity=\"sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65\" crossorigin=\"anonymous\">\n    \n\n    \n        <div class=\"container\">\n            <form method=\"POST\" action=\"{{ route('validate.address') }}\" class=\"mt-5 p-4 border rounded\">\n                @csrf\n                <h2 class=\"text-center mb-4\">Street <a href=\"https:\/\/www.geopostcodes.com\/en-GB\/address-validation-service\/\">Address Validation<\/a><\/h2>\n\n                <!-- Success Message -->\n                @if (session('success'))\n                <div class=\"alert alert-success\">{{ session('success') }}<\/div>\n                @endif\n\n                <!-- Validation Errors -->\n                @if ($errors-&gt;any())\n                <div class=\"alert alert-danger\">\n                    @foreach ($errors-&gt;all() as $error)\n                    <p>{{ $error }}<\/p>\n                    @endforeach\n                <\/div>\n                @endif\n\n                <!-- Street -->\n                <div class=\"mb-3\">\n                    <label for=\"street\" class=\"form-label\">Street<\/label>\n                    <input type=\"text\" class=\"form-control\" id=\"street\" name=\"street\" value=\"{{ old('street') }}\" required=\"\">\n                <\/div>\n\n                <!-- City -->\n                <div class=\"mb-3\">\n                    <label for=\"city\" class=\"form-label\">City<\/label>\n                    <input type=\"text\" class=\"form-control\" id=\"city\" name=\"city\" value=\"{{ old('city') }}\" required=\"\">\n                <\/div>\n\n                <!-- State -->\n                <div class=\"mb-3\">\n                    <label for=\"state\" class=\"form-label\">State<\/label>\n                    <input type=\"text\" class=\"form-control\" id=\"state\" name=\"state\" value=\"{{ old('state') }}\" required=\"\">\n                <\/div>\n\n                <!-- Postcode -->\n                <div class=\"mb-3\">\n                    <label for=\"zip_code\" class=\"form-label\">Postcode<\/label>\n                    <input type=\"text\" class=\"form-control\" id=\"zip_code\" name=\"zip_code\" value=\"{{ old('zip_code') }}\" required=\"\">\n                <\/div>\n\n                <!-- Submit Button -->\n                <button type=\"submit\" class=\"btn btn-primary\">\n                    Validate Address\n                <\/button>\n            <\/form>\n        <\/div>\n    \n<\/pre>\n\n\n\n<p>The form includes fields for entering the street, city, state, and postcode, each with validation to ensure they are completed. The form displays success or error messages received from the backend. It uses Bootstrap for styling and includes a CSRF token for security.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Testing the Application<\/h2>\n\n\n\n<p>To test if everything is working as expected, run the Laravel server by executing the command below in the terminal:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"php\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">php artisan serve<\/pre>\n\n\n\n<p>Navigate to <code>http:\/\/localhost:8000<\/code> in your web browser.<\/p>\n\n\n\n<p>In the displayed HTML form, let&#8217;s test what will happen if you provide an address with an incorrect postcode. Use &#8220;East 136th Street&#8221; as the street, &#8220;Chicago&#8221; as the city, &#8220;Illinois&#8221; as the state, and &#8220;60634&#8221; as the postcode.<\/p>\n\n\n\n<p><em>Note:<\/em> GeoPostcodes&#8217; sample data only includes a few addresses for testing purposes. If you try to input a valid address in the North American region that is not listed in the sample dataset, the application will return an error indicating that the address provided is invalid.<\/p>\n\n\n\n<p>The form will display an error indicating that the address you provided is invalid:<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"485\" src=\"https:\/\/www.geopostcodes.com\/en-GB\/wp-content\/uploads\/2024\/08\/Tbn1MKr-1024x485.webp\" alt=\"php street address validation\" class=\"wp-image-22913\" srcset=\"https:\/\/www.geopostcodes.com\/en-GB\/wp-content\/uploads\/2024\/08\/Tbn1MKr-1024x485.webp 1024w, https:\/\/www.geopostcodes.com\/en-GB\/wp-content\/uploads\/2024\/08\/Tbn1MKr-300x142.webp 300w, https:\/\/www.geopostcodes.com\/en-GB\/wp-content\/uploads\/2024\/08\/Tbn1MKr-768x364.webp 768w, https:\/\/www.geopostcodes.com\/en-GB\/wp-content\/uploads\/2024\/08\/Tbn1MKr.webp 1400w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<div style=\"height:40px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>Now, provide the correct postcode (&#8220;60633&#8221;). The form will display a success message:<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"485\" src=\"https:\/\/www.geopostcodes.com\/en-GB\/wp-content\/uploads\/2024\/08\/l210ud9-1024x485.webp\" alt=\"php street address validation\" class=\"wp-image-22909\" srcset=\"https:\/\/www.geopostcodes.com\/en-GB\/wp-content\/uploads\/2024\/08\/l210ud9-1024x485.webp 1024w, https:\/\/www.geopostcodes.com\/en-GB\/wp-content\/uploads\/2024\/08\/l210ud9-300x142.webp 300w, https:\/\/www.geopostcodes.com\/en-GB\/wp-content\/uploads\/2024\/08\/l210ud9-768x364.webp 768w, https:\/\/www.geopostcodes.com\/en-GB\/wp-content\/uploads\/2024\/08\/l210ud9.webp 1400w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<div style=\"height:40px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>This confirms that everything is working as expected.<\/p>\n\n\n\n<p>You can access the full project code for this tutorial on <a href=\"https:\/\/github.com\/kimanikevin254\/geopostcodes-laravel-street-address-validation\" target=\"_blank\" rel=\"noreferrer noopener\">GitHub<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">The Value of a Comprehensive International Address Database<\/h2>\n\n\n\n<p>Even though this article only showed how to validate US addresses, using a comprehensive database is even more important if you need to <a href=\"https:\/\/www.geopostcodes.com\/en-GB\/blog\/international-address-validation\/\" target=\"_blank\" rel=\"noreferrer noopener\">validate addresses on a global scale<\/a>.<\/p>\n\n\n\n<p>An <a href=\"https:\/\/www.geopostcodes.com\/en-GB\/blog\/international-address-data\/\" target=\"_blank\" rel=\"noreferrer noopener\">address format<\/a> can consist of a number, complex or building name, street, <a href=\"https:\/\/www.geopostcodes.com\/en-GB\/blog\/international-zip-code-format\/\" target=\"_blank\" rel=\"noreferrer noopener\">postcode<\/a>, locality, and administrative division. How these are presented can differ considerably between regions. For instance, the number may be written before or after the street name, or, in some cases, it might even be omitted because the building is prominent enough. If the building is an apartment complex, there could be an additional number associated with the building to indicate the occupant&#8217;s unit.<\/p>\n\n\n\n<p>Different countries also use different principles for abbreviations. For instance, in France, &#8220;ST&#8221; is short for the municipality name &#8220;Saint,&#8221; while other countries use &#8220;ST&#8221; or &#8220;St&#8221; as an abbreviation for &#8220;street.&#8221; Even if you could use capitalization to differentiate between the uses in this case, remember that people from different countries will not have this context. They could also make mistakes when typing.<\/p>\n\n\n\n<p>Using a normalized global address list like <span style=\"margin: 0px;padding: 0px\"><a href=\"https:\/\/www.geopostcodes.com\/en-GB\" target=\"_blank\" rel=\"noopener\">GeoPostcodes<\/a>&nbsp;caters to all <\/span>these needs, so you do not have to clean data and write ever more complex regular expressions&nbsp;to validate addresses.<\/p>\n\n\n\n<p>GeoPostcodes offers data at three region levels\u2014for example, in the US, you have national, state, and county data. We also offer data in multiple languages for countries with multiple official ones, like Switzerland.<\/p>\n\n\n\n<p>The data is available in normalized and denormalized form, making it easy to import into existing systems. It is consistently updated, cleaned, and standardized to ensure it is ready for use.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>Congratulations! You now know how to build a robust <a href=\"https:\/\/www.geopostcodes.com\/en-GB\/address-validation-service\/\">address validation<\/a> in PHP using GeoPostcodes&#8217; accurate street address data, whether it is to reduce the risk of undeliverable or late shipments, improve customer satisfaction, and optimize delivery routes.<\/p>\n\n\n\n<p><a href=\"https:\/\/www.geopostcodes.com\/en-GB\/\" target=\"_blank\" rel=\"noreferrer noopener\">GeoPostcodes<\/a> offers comprehensive and accurate postal and postcode data to ensure the reliability of <a href=\"https:\/\/www.geopostcodes.com\/en-GB\/address-validation-service\/\">address validation<\/a> systems. Its databases provide extensive coverage and up-to-date postal information, making it easier for businesses to maintain accurate customer records and ensure efficient operations.<\/p>\n\n\n\n<p>Use GeoPostcodes to streamline your data validation processes and deliver better service to your customers.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">FAQ<\/h2>\n\n\n\n<div id=\"wp-block-themeisle-blocks-accordion-aa5641a4\" class=\"wp-block-themeisle-blocks-accordion exclusive has-light-content-bg is-style-default\">\n<details class=\"wp-block-themeisle-blocks-accordion-item\"><summary class=\"wp-block-themeisle-blocks-accordion-item__title\"><div><strong>What constitutes a complete address for validation purposes?<\/strong><\/div><\/summary><div class=\"wp-block-themeisle-blocks-accordion-item__content\">\n<div style=\"height:40px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>A complete address includes several key components: a street name, street number, city, state, and postcode. <\/p>\n\n\n\n<p>For effective validation, each of these elements must be present and correctly formatted. <\/p>\n\n\n\n<p>Ensuring a complete address helps prevent errors in deliveries and ensures that communications reach the correct destination without issues.<\/p>\n\n\n\n<div style=\"height:10px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n<\/div><\/details>\n\n\n\n<details class=\"wp-block-themeisle-blocks-accordion-item\"><summary class=\"wp-block-themeisle-blocks-accordion-item__title\"><div><strong>What is PHP street address validation?<\/strong><\/div><\/summary><div class=\"wp-block-themeisle-blocks-accordion-item__content\">\n<div style=\"height:40px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>PHP street <a href=\"https:\/\/www.geopostcodes.com\/en-GB\/address-validation-service\/\">address validation<\/a> is a process that verifies the accuracy and completeness of addresses submitted by users. <\/p>\n\n\n\n<p>This ensures that the addresses are real and correctly formatted according to postal standards, helping businesses prevent issues like failed deliveries or sending information to incorrect locations.<\/p>\n\n\n\n<div style=\"height:10px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n<\/div><\/details>\n\n\n\n<details class=\"wp-block-themeisle-blocks-accordion-item\"><summary class=\"wp-block-themeisle-blocks-accordion-item__title\"><div><strong>How do you validate street addresses using a regular expression in PHP?<\/strong><\/div><\/summary><div class=\"wp-block-themeisle-blocks-accordion-item__content\">\n<div style=\"height:40px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>To validate street addresses using a regular expression in PHP, you can create patterns that check if the street name and street number follow the expected format. <\/p>\n\n\n\n<p>Regular expressions help ensure that the input matches predefined criteria, such as specific character sequences, before proceeding with further validation steps.<\/p>\n\n\n\n<div style=\"height:10px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n<\/div><\/details>\n\n\n\n<details class=\"wp-block-themeisle-blocks-accordion-item\"><summary class=\"wp-block-themeisle-blocks-accordion-item__title\"><div><strong>What does &#8220;a za z&#8221; mean in regular expressions?<\/strong><\/div><\/summary><div class=\"wp-block-themeisle-blocks-accordion-item__content\">\n<div style=\"height:40px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>In regular expressions, &#8220;a za z&#8221; refers to a character set that matches any single lowercase or uppercase letter. <\/p>\n\n\n\n<p>The pattern [A-Za-z] specifies that any letter between A-Z, either in uppercase or lowercase, is acceptable. The hyphen (-) in the pattern indicates a range of characters to include.<\/p>\n\n\n\n<div style=\"height:10px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n<\/div><\/details>\n\n\n\n<details class=\"wp-block-themeisle-blocks-accordion-item\"><summary class=\"wp-block-themeisle-blocks-accordion-item__title\"><div><strong>What role does the USPS API play in street address validation?<\/strong><\/div><\/summary><div class=\"wp-block-themeisle-blocks-accordion-item__content\">\n<div style=\"height:40px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>The USPS API is an essential tool for validating street addresses in the United States. <\/p>\n\n\n\n<p>It ensures that addresses, including street names and street numbers, conform to USPS formatting guidelines, which helps improve the accuracy of deliveries and reduces the risk of address-related errors.<\/p>\n\n\n\n<div style=\"height:10px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n<\/div><\/details>\n\n  \n  <details class=\"wp-block-themeisle-blocks-accordion-item\">\n    <summary class=\"wp-block-themeisle-blocks-accordion-item__title\">\n      <div><strong>What database should I use for PHP address validation?<\/strong><\/div>\n    <\/summary>\n    <div class=\"wp-block-themeisle-blocks-accordion-item__content\">\n      \n      <div style=\"height:40px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n      \n\n      \n      <p>GeoPostcodes provides a comprehensive <a href=\"https:\/\/www.geopostcodes.com\/en-GB\/address-validation-database\/\">address validation database<\/a> that can be easily integrated with PHP applications for reliable address verification.<\/p>\n      \n\n      \n      <div style=\"height:10px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n      \n    <\/div>\n  <\/details>\n  \n\n  \n  <details class=\"wp-block-themeisle-blocks-accordion-item\">\n    <summary class=\"wp-block-themeisle-blocks-accordion-item__title\">\n      <div><strong>How can I validate US addresses in PHP?<\/strong><\/div>\n    <\/summary>\n    <div class=\"wp-block-themeisle-blocks-accordion-item__content\">\n      \n      <div style=\"height:40px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n      \n\n      \n      <p>For US addresses, integrate GeoPostcodes&#8217; <a href=\"https:\/\/www.geopostcodes.com\/en-GB\/usps-address-verification-tool\/\">USPS address verification database<\/a> or use our <a href=\"https:\/\/www.geopostcodes.com\/en-GB\/master-address-list\/\">list of US addresses<\/a> for validation in PHP applications.<\/p>\n      \n\n      \n      <div style=\"height:10px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n      \n    <\/div>\n  <\/details>\n  \n\n  \n  <details class=\"wp-block-themeisle-blocks-accordion-item\">\n    <summary class=\"wp-block-themeisle-blocks-accordion-item__title\">\n      <div><strong>How can I perform batch address validation?<\/strong><\/div>\n    <\/summary>\n    <div class=\"wp-block-themeisle-blocks-accordion-item__content\">\n      \n      <div style=\"height:40px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n      \n\n      \n      <p>GeoPostcodes provides <a href=\"https:\/\/www.geopostcodes.com\/en-GB\/address-validation-service\/\">batch address verification<\/a> capabilities for processing large volumes of addresses.<\/p>\n      \n\n      \n      <div style=\"height:10px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n      \n    <\/div>\n  <\/details>\n  \n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Learn how to implement PHP street address validation using GeoPostcodes for accurate, reliable, and efficient postal data verification.<\/p>\n","protected":false},"author":41,"featured_media":22901,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"set","_themeisle_gutenberg_block_has_review":false,"footnotes":""},"categories":[41],"tags":[],"class_list":["post-22887","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-address-validation"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.7 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>PHP Street Address Validation<\/title>\n<meta name=\"description\" content=\"Learn how to implement PHP street address validation using GeoPostcodes for accurate, reliable, and efficient postal data verification.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.geopostcodes.com\/en-GB\/blog\/php-street-address-validation\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"PHP Street Address Validation\" \/>\n<meta property=\"og:description\" content=\"Learn how to implement PHP street address validation using GeoPostcodes for accurate, reliable, and efficient postal data verification.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.geopostcodes.com\/en-GB\/blog\/php-street-address-validation\/\" \/>\n<meta property=\"og:site_name\" content=\"GeoPostcodes\" \/>\n<meta property=\"article:published_time\" content=\"2024-08-30T10:01:03+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-04-01T07:01:01+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.geopostcodes.com\/wp-content\/uploads\/2024\/08\/GeoPostcodes-PHP-address-validation.webp\" \/>\n\t<meta property=\"og:image:width\" content=\"800\" \/>\n\t<meta property=\"og:image:height\" content=\"320\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/webp\" \/>\n<meta name=\"author\" content=\"Kevin Kimani\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Kevin Kimani\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"11 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.geopostcodes.com\/en-GB\/blog\/php-street-address-validation\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.geopostcodes.com\/en-GB\/blog\/php-street-address-validation\/\"},\"author\":{\"name\":\"Kevin Kimani\",\"@id\":\"https:\/\/www.geopostcodes.com\/en-GB\/#\/schema\/person\/8e1acb10fcf21cd2cc2e6554c70a2675\"},\"headline\":\"PHP Street Address Validation\",\"datePublished\":\"2024-08-30T10:01:03+00:00\",\"dateModified\":\"2026-04-01T07:01:01+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.geopostcodes.com\/en-GB\/blog\/php-street-address-validation\/\"},\"wordCount\":2067,\"publisher\":{\"@id\":\"https:\/\/www.geopostcodes.com\/en-GB\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.geopostcodes.com\/en-GB\/blog\/php-street-address-validation\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.geopostcodes.com\/en-GB\/wp-content\/uploads\/2024\/08\/GeoPostcodes-PHP-address-validation.webp\",\"articleSection\":[\"Address Validation\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.geopostcodes.com\/en-GB\/blog\/php-street-address-validation\/\",\"url\":\"https:\/\/www.geopostcodes.com\/en-GB\/blog\/php-street-address-validation\/\",\"name\":\"PHP Street Address Validation\",\"isPartOf\":{\"@id\":\"https:\/\/www.geopostcodes.com\/en-GB\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.geopostcodes.com\/en-GB\/blog\/php-street-address-validation\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.geopostcodes.com\/en-GB\/blog\/php-street-address-validation\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.geopostcodes.com\/en-GB\/wp-content\/uploads\/2024\/08\/GeoPostcodes-PHP-address-validation.webp\",\"datePublished\":\"2024-08-30T10:01:03+00:00\",\"dateModified\":\"2026-04-01T07:01:01+00:00\",\"description\":\"Learn how to implement PHP street address validation using GeoPostcodes for accurate, reliable, and efficient postal data verification.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.geopostcodes.com\/en-GB\/blog\/php-street-address-validation\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.geopostcodes.com\/en-GB\/blog\/php-street-address-validation\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.geopostcodes.com\/en-GB\/blog\/php-street-address-validation\/#primaryimage\",\"url\":\"https:\/\/www.geopostcodes.com\/en-GB\/wp-content\/uploads\/2024\/08\/GeoPostcodes-PHP-address-validation.webp\",\"contentUrl\":\"https:\/\/www.geopostcodes.com\/en-GB\/wp-content\/uploads\/2024\/08\/GeoPostcodes-PHP-address-validation.webp\",\"width\":800,\"height\":320,\"caption\":\"GeoPostcodes-PHP address validation\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.geopostcodes.com\/en-GB\/blog\/php-street-address-validation\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.geopostcodes.be\/en-GB\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"PHP Street Address Validation\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.geopostcodes.com\/en-GB\/#website\",\"url\":\"https:\/\/www.geopostcodes.com\/en-GB\/\",\"name\":\"GeoPostcodes\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/www.geopostcodes.com\/en-GB\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.geopostcodes.com\/en-GB\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.geopostcodes.com\/en-GB\/#organization\",\"name\":\"GeoPostcodes\",\"url\":\"https:\/\/www.geopostcodes.com\/en-GB\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.geopostcodes.com\/en-GB\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.geopostcodes.com\/en-GB\/wp-content\/uploads\/2021\/04\/cropped-GeoPostcodes-color@2x-png.webp\",\"contentUrl\":\"https:\/\/www.geopostcodes.com\/en-GB\/wp-content\/uploads\/2021\/04\/cropped-GeoPostcodes-color@2x-png.webp\",\"width\":1331,\"height\":207,\"caption\":\"GeoPostcodes\"},\"image\":{\"@id\":\"https:\/\/www.geopostcodes.com\/en-GB\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.geopostcodes.com\/en-GB\/#\/schema\/person\/8e1acb10fcf21cd2cc2e6554c70a2675\",\"name\":\"Kevin Kimani\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.geopostcodes.com\/en-GB\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/www.geopostcodes.com\/wp-content\/uploads\/2024\/08\/cropped-vq__VSiwvCw5VvctEv1xpaDR1qLQ40P3fI1A2MhO688.webp\",\"contentUrl\":\"https:\/\/www.geopostcodes.com\/wp-content\/uploads\/2024\/08\/cropped-vq__VSiwvCw5VvctEv1xpaDR1qLQ40P3fI1A2MhO688.webp\",\"caption\":\"Kevin Kimani\"},\"description\":\"Hello, I'm Kevin Kimani. I'm a Full Stack Developer specializing in the MERN stack (MongoDB, Express.js, React, Node.js), NestJS, NextJs, React Native, TypeScript, and JavaScript. With a passion for creating dynamic and responsive web applications and cross-platform mobile applications, I also enjoy writing technical articles and contributing to open-source projects.\",\"url\":\"https:\/\/www.geopostcodes.com\/en-GB\/blog\/author\/kevin-kimani\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"PHP Street Address Validation","description":"Learn how to implement PHP street address validation using GeoPostcodes for accurate, reliable, and efficient postal data verification.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.geopostcodes.com\/en-GB\/blog\/php-street-address-validation\/","og_locale":"en_US","og_type":"article","og_title":"PHP Street Address Validation","og_description":"Learn how to implement PHP street address validation using GeoPostcodes for accurate, reliable, and efficient postal data verification.","og_url":"https:\/\/www.geopostcodes.com\/en-GB\/blog\/php-street-address-validation\/","og_site_name":"GeoPostcodes","article_published_time":"2024-08-30T10:01:03+00:00","article_modified_time":"2026-04-01T07:01:01+00:00","og_image":[{"width":800,"height":320,"url":"https:\/\/www.geopostcodes.com\/wp-content\/uploads\/2024\/08\/GeoPostcodes-PHP-address-validation.webp","type":"image\/webp"}],"author":"Kevin Kimani","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Kevin Kimani","Est. reading time":"11 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.geopostcodes.com\/en-GB\/blog\/php-street-address-validation\/#article","isPartOf":{"@id":"https:\/\/www.geopostcodes.com\/en-GB\/blog\/php-street-address-validation\/"},"author":{"name":"Kevin Kimani","@id":"https:\/\/www.geopostcodes.com\/en-GB\/#\/schema\/person\/8e1acb10fcf21cd2cc2e6554c70a2675"},"headline":"PHP Street Address Validation","datePublished":"2024-08-30T10:01:03+00:00","dateModified":"2026-04-01T07:01:01+00:00","mainEntityOfPage":{"@id":"https:\/\/www.geopostcodes.com\/en-GB\/blog\/php-street-address-validation\/"},"wordCount":2067,"publisher":{"@id":"https:\/\/www.geopostcodes.com\/en-GB\/#organization"},"image":{"@id":"https:\/\/www.geopostcodes.com\/en-GB\/blog\/php-street-address-validation\/#primaryimage"},"thumbnailUrl":"https:\/\/www.geopostcodes.com\/en-GB\/wp-content\/uploads\/2024\/08\/GeoPostcodes-PHP-address-validation.webp","articleSection":["Address Validation"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.geopostcodes.com\/en-GB\/blog\/php-street-address-validation\/","url":"https:\/\/www.geopostcodes.com\/en-GB\/blog\/php-street-address-validation\/","name":"PHP Street Address Validation","isPartOf":{"@id":"https:\/\/www.geopostcodes.com\/en-GB\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.geopostcodes.com\/en-GB\/blog\/php-street-address-validation\/#primaryimage"},"image":{"@id":"https:\/\/www.geopostcodes.com\/en-GB\/blog\/php-street-address-validation\/#primaryimage"},"thumbnailUrl":"https:\/\/www.geopostcodes.com\/en-GB\/wp-content\/uploads\/2024\/08\/GeoPostcodes-PHP-address-validation.webp","datePublished":"2024-08-30T10:01:03+00:00","dateModified":"2026-04-01T07:01:01+00:00","description":"Learn how to implement PHP street address validation using GeoPostcodes for accurate, reliable, and efficient postal data verification.","breadcrumb":{"@id":"https:\/\/www.geopostcodes.com\/en-GB\/blog\/php-street-address-validation\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.geopostcodes.com\/en-GB\/blog\/php-street-address-validation\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.geopostcodes.com\/en-GB\/blog\/php-street-address-validation\/#primaryimage","url":"https:\/\/www.geopostcodes.com\/en-GB\/wp-content\/uploads\/2024\/08\/GeoPostcodes-PHP-address-validation.webp","contentUrl":"https:\/\/www.geopostcodes.com\/en-GB\/wp-content\/uploads\/2024\/08\/GeoPostcodes-PHP-address-validation.webp","width":800,"height":320,"caption":"GeoPostcodes-PHP address validation"},{"@type":"BreadcrumbList","@id":"https:\/\/www.geopostcodes.com\/en-GB\/blog\/php-street-address-validation\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.geopostcodes.be\/en-GB\/"},{"@type":"ListItem","position":2,"name":"PHP Street Address Validation"}]},{"@type":"WebSite","@id":"https:\/\/www.geopostcodes.com\/en-GB\/#website","url":"https:\/\/www.geopostcodes.com\/en-GB\/","name":"GeoPostcodes","description":"","publisher":{"@id":"https:\/\/www.geopostcodes.com\/en-GB\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.geopostcodes.com\/en-GB\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.geopostcodes.com\/en-GB\/#organization","name":"GeoPostcodes","url":"https:\/\/www.geopostcodes.com\/en-GB\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.geopostcodes.com\/en-GB\/#\/schema\/logo\/image\/","url":"https:\/\/www.geopostcodes.com\/en-GB\/wp-content\/uploads\/2021\/04\/cropped-GeoPostcodes-color@2x-png.webp","contentUrl":"https:\/\/www.geopostcodes.com\/en-GB\/wp-content\/uploads\/2021\/04\/cropped-GeoPostcodes-color@2x-png.webp","width":1331,"height":207,"caption":"GeoPostcodes"},"image":{"@id":"https:\/\/www.geopostcodes.com\/en-GB\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/www.geopostcodes.com\/en-GB\/#\/schema\/person\/8e1acb10fcf21cd2cc2e6554c70a2675","name":"Kevin Kimani","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.geopostcodes.com\/en-GB\/#\/schema\/person\/image\/","url":"https:\/\/www.geopostcodes.com\/wp-content\/uploads\/2024\/08\/cropped-vq__VSiwvCw5VvctEv1xpaDR1qLQ40P3fI1A2MhO688.webp","contentUrl":"https:\/\/www.geopostcodes.com\/wp-content\/uploads\/2024\/08\/cropped-vq__VSiwvCw5VvctEv1xpaDR1qLQ40P3fI1A2MhO688.webp","caption":"Kevin Kimani"},"description":"Hello, I'm Kevin Kimani. I'm a Full Stack Developer specializing in the MERN stack (MongoDB, Express.js, React, Node.js), NestJS, NextJs, React Native, TypeScript, and JavaScript. With a passion for creating dynamic and responsive web applications and cross-platform mobile applications, I also enjoy writing technical articles and contributing to open-source projects.","url":"https:\/\/www.geopostcodes.com\/en-GB\/blog\/author\/kevin-kimani\/"}]}},"jetpack_featured_media_url":"https:\/\/www.geopostcodes.com\/en-GB\/wp-content\/uploads\/2024\/08\/GeoPostcodes-PHP-address-validation.webp","_links":{"self":[{"href":"https:\/\/www.geopostcodes.com\/en-GB\/wp-json\/wp\/v2\/posts\/22887","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.geopostcodes.com\/en-GB\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.geopostcodes.com\/en-GB\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.geopostcodes.com\/en-GB\/wp-json\/wp\/v2\/users\/41"}],"replies":[{"embeddable":true,"href":"https:\/\/www.geopostcodes.com\/en-GB\/wp-json\/wp\/v2\/comments?post=22887"}],"version-history":[{"count":1,"href":"https:\/\/www.geopostcodes.com\/en-GB\/wp-json\/wp\/v2\/posts\/22887\/revisions"}],"predecessor-version":[{"id":43050,"href":"https:\/\/www.geopostcodes.com\/en-GB\/wp-json\/wp\/v2\/posts\/22887\/revisions\/43050"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.geopostcodes.com\/en-GB\/wp-json\/wp\/v2\/media\/22901"}],"wp:attachment":[{"href":"https:\/\/www.geopostcodes.com\/en-GB\/wp-json\/wp\/v2\/media?parent=22887"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.geopostcodes.com\/en-GB\/wp-json\/wp\/v2\/categories?post=22887"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.geopostcodes.com\/en-GB\/wp-json\/wp\/v2\/tags?post=22887"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}