• 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

Laravel: HTML in notification

get attribute from class not working php 7

Woocommerce product attributes with hierarchy like categories

Comma separated list from array with "and" before last element

Why rand() every time I refresh the page?

Laravel - Browser displays message again when I press back button

oauth-private.key does not exist or is not readable

Combine array with same value and add other [duplicate]

Why is this PHP array not the same?

Group data in a multidimensional array based on two columns

Download & Save Zoom Recording in directory by PHP

Laravel Displaying image from database

PDOException SQLSTATE[HY000] [2002] No such file or directory

Laravel Multi-language routes without prefix

json_encode turns array into an object

About Contact Privacy policy Terms and conditions