Model/Address.php
public function splitShipToStreetPayPalAddress($shipToStreet)
    {
        $address = array();
        $shipToStreet = trim($shipToStreet);

        // checking if street number is at the end of the address
        preg_match("/(.*\S)\s+(\d+\s*\S*)$/", $shipToStreet, $address);

        // checking if street name and number was found
        if (!empty($address[1]) && $address[2]) {
            $address['street'] = $address[1];
            $address['streetnr'] = $address[2];

            return $address;
        }

        // checking if street number is at the begining of the address
        preg_match("/(\d+\S*)\s+(.*)$/", $shipToStreet, $address);

        // checking if street name and number was found
        if (!empty($address[1]) && $address[2]) {
            $address['street'] = $address[2];
            $address['streetnr'] = $address[1];

            return $address;
        }

        // it is not possible to resolve address, so assign it without any parsing
        $address['street'] = $shipToStreet;
        $address['streetnr'] = "";

        return $address;
    }
public function splitShipToStreetPayPalAddress($shipToStreet)
    {
        $address = array();
        $shipToStreet = trim($shipToStreet);

        // checking if street number is at the end of the address
        preg_match("/(.*\S)\s+(\d+\s*\S*)$/", $shipToStreet, $address);

        // checking if street name and number was found
        if (!empty($address[1]) && $address[2]) {
            $address['street'] = $address[1];
            $address['streetnr'] = $address[2];

            return $address;
        }

        // checking if street number is at the begining of the address
        preg_match("/(\d+\S*)\s+(.*)$/", $shipToStreet, $address);

        // checking if street name and number was found
        if (!empty($address[1]) && $address[2]) {
            $address['street'] = $address[2];
            $address['streetnr'] = $address[1];

            return $address;
        }

        // it is not possible to resolve address, so assign it without any parsing
        $address['street'] = $shipToStreet;
        $address['streetnr'] = "";

        return $address;
    }
public function splitShipToStreetPayPalAddress ( $ shipToStreet ) { $ address = array ( ) ; $ shipToStreet = trim ( $ shipToStreet ) ; // checking if street number is at the end of the address preg_match ( "/(.*\S)\s+(\d+\s*\S*)$/" , $ shipToStreet , $ address ) ; // checking if street name and number was found if ( ! empty ( $ address [ 1 ] ) && $ address [ 2 ] ) { $ address [ 'street' ] = $ address [ 1 ] ; $ address [ 'streetnr' ] = $ address [ 2 ] ; return $ address ; } // checking if street number is at the begining of the address preg_match ( "/(\d+\S*)\s+(.*)$/" , $ shipToStreet , $ address ) ; // checking if street name and number was found if ( ! empty ( $ address [ 1 ] ) && $ address [ 2 ] ) { $ address [ 'street' ] = $ address [ 2 ] ; $ address [ 'streetnr' ] = $ address [ 1 ] ; return $ address ; } // it is not possible to resolve address, so assign it without any parsing $ address [ 'street' ] = $ shipToStreet ; $ address [ 'streetnr' ] = "" ; return $ address ; }
Split street nr from address

@param string $shipToStreet address string

@return array
Split street nr from address