• 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

How do I Post to .txt document before form submits

Symfony Error: "An exception has been thrown during the rendering of a template"

php echo remove slashes from url [duplicate]

HTTP Range requests with php for Video Embedding for solving going to specific time in video (seek bar not work)

PHPMetrics option --excluded-dirs="myfolder" : myfolder dir is not excluded within docker

How to read laravel_session cookies saved in cookie memory of browser in client side?

Convert date and time to Jalali in Laravel

Cant seem to get the Pagination to work on my WooCommerce REST API application?

Auto increment id JSON

How to auto populate preferredCountries from intl-tel-input with db output

Dynamic table in HTML using MySQL and php

Using array_intersect on a multi-dimensional array

Sentry + Laravel: how to log an already catched Exception?

Twig - How to check if variable is a number / integer

Normalize DateInterval in PHP

About Contact Privacy policy Terms and conditions