• Categories
    • PHP
    • phpMyAdmin
    • PHPMailer
    • FFMpeg
    • PHPEXcel
    • PHPDoc
    • PHPUnit
    • CakePHP
    • CakePHP 2.0
    • Cake PHP 2.1
    • CakePHP Model
    • Facebook PHP SDK
    • composer-php
    • PHP 7
    • PHP GD
    All Categories
  • About

Extract house numbers from address string

phpregexstreet-address


PHP Snippet 1:

preg_match_all('!\s(\d.*)!', 'streetname 60/2/3', $matches);

PHP Snippet 2:

function getStreetNumberFromStreetAddress($streetAddress){
  $array = explode(' ',$streetAddress);

  if (count($array) > 0){
    foreach($array as $a){
      if (is_numeric($a[0])){
        return $a;
      }
    }
  }
  return null;
}

Related Snippets

VB.NET WebRequest with PHP POST

Exact alternate to mcrypt_encrypt in PHP 7.2

Required field only if another field has a value, must be empty otherwise

Transform array, set each array element with parent key php

PHP cURL (SSL certificate problem: self signed certificate in certificate chain)

Laravel 5.1 how to use {{ old('') }} helper on blade file for radio inputs

Upload a file Using PHP and JavaScript

laravel MVC execution flow

Cannot retrieve error message using Symfony HttpClient if the response is not "ok"

Doctrine ORM: Excluding Records Based on Values of Nested Relationships

SendGrid: Sending an email to multiple recipients without other emails being shown on the "to" field

How to change product Image when variables are selected in Shop and Archive Pages?

Laravel/ PHP: Order By Alphabetical with numbers in order [duplicate]

error:14094410:SSL routines:ssl3_read_bytes:sslv3 alert handshake failure

PHP - Check if string contains words longer than 4 characters, then include "+ *", and for those shorter than 4 characters include only "*"

About Contact Privacy policy Terms and conditions