protected function extractNumberAndGetPosition($datetimeToParse, &$position)
    {
        $characters = str_split($datetimeToParse);

        $number = '';
        $numberStarted = false;
        foreach ($characters as $index => $character) {
            if (ord($character) >= 48 && ord($character) <= 57) {
                if (!$numberStarted) {
                    $numberStarted = true;
                    $position = $index;
                }
                $number .= $character;
            } elseif ($numberStarted) {
                return $number;
            }
        }

        if ($numberStarted) {
            return $number;
        }

        throw new Exception\InvalidParseStringException('Expected number not found in the string.', 1280498431);
    }
protected function extractNumberAndGetPosition($datetimeToParse, &$position)
    {
        $characters = str_split($datetimeToParse);

        $number = '';
        $numberStarted = false;
        foreach ($characters as $index => $character) {
            if (ord($character) >= 48 && ord($character) <= 57) {
                if (!$numberStarted) {
                    $numberStarted = true;
                    $position = $index;
                }
                $number .= $character;
            } elseif ($numberStarted) {
                return $number;
            }
        }

        if ($numberStarted) {
            return $number;
        }

        throw new Exception\InvalidParseStringException('Expected number not found in the string.', 1280498431);
    }
protected function extractNumberAndGetPosition ( $ datetimeToParse , & $ position ) { $ characters = str_split ( $ datetimeToParse ) ; $ number = '' ; $ numberStarted = false ; foreach ( $ characters as $ index => $ character ) { if ( ord ( $ character ) >= 48 && ord ( $ character ) <= 57 ) { if ( ! $ numberStarted ) { $ numberStarted = true ; $ position = $ index ; } $ number .= $ character ; } elseif ( $ numberStarted ) { return $ number ; } } if ( $ numberStarted ) { return $ number ; } throw new Exception \ InvalidParseStringException ( 'Expected number not found in the string.' , 1280498431 ) ; }
Extracts and returns first integer number encountered in provided string.

Searches for first digit and extracts all adjacent digits. Also returns
position of first digit in string.

@param string $datetimeToParse String to search number in
@param int $position Index of first digit in string
@return string Extracted number
@throws Exception\InvalidParseStringException When no digit found in string
Extracts and returns first integer number encountered in provided string .