• 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

MOODLE: What does it mean to aggregate h5p assets?

Why getting "Build step 'Execute shell' marked build as failure" error while creating a backup tar for files

How to get variable from JavaScript to PHP [duplicate]

Webscraping Symfony/Panther: Can't get HTML

Laravel SQL query midnight time not showing

Input and output values for php into the browser?

Explode not working properly with dash

Upgrade PHP on AWS Linux

Populate Dynamic Dropdowns List in Codeigniter

PHP 8.1: strftime() is deprecated

How to make autocomplete work in foreach php loop? (vscode, intellisense)

How to display MySQL table using php and edit it in a web browser

Download & Save Zoom Recording in directory by PHP

Updating and Synchronizing Woocommerce Subscriptions to Custom Date

zsh: command not found: php

About Contact Privacy policy Terms and conditions