• 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

Store / Website Column in Magento 2 Admin Grid - Custom Module

how to hide previous markers when new markers added in google map javascript api

How to insert data from multiple select dropdown values into database?

Encrypt in php and decrypt in Dart(flutter)

How to get median and quartiles/percentiles of an array in JavaScript (or PHP)?

Unable to guess the mime type as no guessers are available Laravel 5.2

Statement that checks whether a URL contains a particular path?

Implode columnar values between two arrays into a flat array of concatenated strings

PDOException: PDO::__construct(): php_network_getaddresses: getaddrinfo failed: no such host known

Laravel insert dynamic input values with radio button

Cross-Origin Resource Sharing (CORS) witth Laravel and Vuejs

How do I get friend list from Friends table with counts of friends of my friends

CSV to PHP class properties

Put content of wordpress page inside div

how to see if database exists with PDO [duplicate]

About Contact Privacy policy Terms and conditions