• 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

Download & Save Zoom Recording in directory by PHP

What is the function of the (new Date()).getTime() in PHP?

Check If array is null or not in php

how to identify the web server name of remote host

Fatal error: Uncaught Error: Call to undefined method mysqli_stmt::fetch_assoc() [duplicate]

Is there a way to correctly use sanitize_text_field and wp_unslash that doesn't cause psalm to error with "expects string, possibly different type"

I want a way to give path to my files which are outside of public folder in laravel

hidden INPUT value not available in $_POST

Two buttons one form

how to check version of codeigniter framework?

Get data from accuweather api url

PHPUnit (Phar) Fatal Error Only When Test Fails

Laravel: HTML in notification

How to create a video stream from a single dynamic image in PHP

How do I upload a laravel project on cPanel shared hosting?

About Contact Privacy policy Terms and conditions