• 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 excel maatwebsite 3.1 import, date column in excel cell returns as unknown format number. How to solve this?

How to get Laravel's CSRF Token from Another Website?

How to MODIFY a Google Docs document via API using search-and-replace?

Json_Encode not returning html even i try to encode JSON_HEX_QUOT | JSON_HEX_TAG

Detect a fetch request in PHP

zsh: command not found: php

storagelogs/laravel.log" could not be opened in append mode: failed to open stream: Permission denied

SQL to convert multiple rows into a single row of variable length

PHPExcel export HTML table to xlsx

How to load Codeigniter 4 lang file into an array variable

add_action() function in wordpress not working [duplicate]

Symfony/Form add attribute based on the data

Laravel Excel::store file empty after stored

Laravel - Implicit route model binding with soft deleted data

Facebook SDK error: Cross-site request forgery validation failed. Required param "state" missing from persistent data

About Contact Privacy policy Terms and conditions