• 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

How to get monthly wise data in laravel

Malformed MIME header error in Symfony 5.3

phpmyadmin : Depends: php-twig (>= 2.9) but 2.6.2-2 is to be installed. WHAT?

Magento 2 - Controller returning blank page

MongoDB Duplicate Documents even after adding unique key

If you intend you use SMTP, add your SMTP Code after this Line

Using array_intersect on a multi-dimensional array

How do I call a php file with axios?

CodeIgniter force_download is not working

Make Calculator - When Button clicked the No shows in Textbox.

Transform array, set each array element with parent key php

unable to load your default controller on Codeigniter

Check if a string contain multiple specific words

Return new collection without modifying original collection

Sync Records With Default Values in Pivot Tables, Call to undefined method syncWithPivotDefaults()

About Contact Privacy policy Terms and conditions