• 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

Add custom text under order details on WooCommerce My account view order pages

printing all running session variable in laravel 5.1

How to send parameters in soap request in php in __soapcall() function

Server-sent events in PHP (without echo or print)

How to increase the PHP upload limits [duplicate]

Populate Dynamic Dropdowns List in Codeigniter

if statement inside concatenation

How can I make a full text index of the column?

The "client_reference_id" argument is not passed

MOODLE: What does it mean to aggregate h5p assets?

PHP using str_starts_with for array to exclude same as with wildcard

Getting error: CodeIgniterDatabaseBaseResult::getResult in CodeIgniter

How to update array value in Laravel

Can't exclude directories from .htaccess mobile redirect?

Laravel Pagination links() not working

About Contact Privacy policy Terms and conditions