original_string: public function parse($value, $type = self::TYPE_DOUBLE, &$position = 0)
      {
          if (self::TYPE_DEFAULT == $type || self::TYPE_CURRENCY == $type) {
              trigger_error(__METHOD__.'(): Unsupported format type '.$type, \E_USER_WARNING);
  
              return false;
          }
  
          // Any invalid number at the end of the string is removed.
          // Only numbers and the fraction separator is expected in the string.
          // If grouping is used, grouping separator also becomes a valid character.
          $groupingMatch = $this->getAttribute(self::GROUPING_USED) ? '|(?P<grouping>\d++(,{1}\d+)++(\.\d*+)?)' : '';
          if (preg_match("/^-?(?:\.\d++{$groupingMatch}|\d++(\.\d*+)?)/", $value, $matches)) {
              $value = $matches[0];
              $position = \strlen($value);
              // value is not valid if grouping is used, but digits are not grouped in groups of three
              if ($error = isset($matches['grouping']) && !preg_match('/^-?(?:\d{1,3}+)?(?:(?:,\d{3})++|\d*+)(?:\.\d*+)?$/', $value)) {
                  // the position on error is 0 for positive and 1 for negative numbers
                  $position = 0 === strpos($value, '-') ? 1 : 0;
              }
          } else {
              $error = true;
              $position = 0;
          }
  
          if ($error) {
              IntlGlobals::setError(IntlGlobals::U_PARSE_ERROR, 'Number parsing failed');
              $this->errorCode = IntlGlobals::getErrorCode();
              $this->errorMessage = IntlGlobals::getErrorMessage();
  
              return false;
          }
  
          $value = str_replace(',', '', $value);
          $value = $this->convertValueDataType($value, $type);
  
          // behave like the intl extension
          $this->resetError();
  
          return $value;
      }
code: public function parse($value, $type = self::TYPE_DOUBLE, &$position = 0)
      {
          if (self::TYPE_DEFAULT == $type || self::TYPE_CURRENCY == $type) {
              trigger_error(__METHOD__.'(): Unsupported format type '.$type, \E_USER_WARNING);
  
              return false;
          }
  
          // Any invalid number at the end of the string is removed.
          // Only numbers and the fraction separator is expected in the string.
          // If grouping is used, grouping separator also becomes a valid character.
          $groupingMatch = $this->getAttribute(self::GROUPING_USED) ? '|(?P<grouping>\d++(,{1}\d+)++(\.\d*+)?)' : '';
          if (preg_match("/^-?(?:\.\d++{$groupingMatch}|\d++(\.\d*+)?)/", $value, $matches)) {
              $value = $matches[0];
              $position = \strlen($value);
              // value is not valid if grouping is used, but digits are not grouped in groups of three
              if ($error = isset($matches['grouping']) && !preg_match('/^-?(?:\d{1,3}+)?(?:(?:,\d{3})++|\d*+)(?:\.\d*+)?$/', $value)) {
                  // the position on error is 0 for positive and 1 for negative numbers
                  $position = 0 === strpos($value, '-') ? 1 : 0;
              }
          } else {
              $error = true;
              $position = 0;
          }
  
          if ($error) {
              IntlGlobals::setError(IntlGlobals::U_PARSE_ERROR, 'Number parsing failed');
              $this->errorCode = IntlGlobals::getErrorCode();
              $this->errorMessage = IntlGlobals::getErrorMessage();
  
              return false;
          }
  
          $value = str_replace(',', '', $value);
          $value = $this->convertValueDataType($value, $type);
  
          // behave like the intl extension
          $this->resetError();
  
          return $value;
      }
code_tokens: public function parse ( $ value , $ type = self :: TYPE_DOUBLE , & $ position = 0 ) { if ( self :: TYPE_DEFAULT == $ type || self :: TYPE_CURRENCY == $ type ) { trigger_error ( __METHOD__ . '(): Unsupported format type ' . $ type , \ E_USER_WARNING ) ; return false ; } // Any invalid number at the end of the string is removed. // Only numbers and the fraction separator is expected in the string. // If grouping is used, grouping separator also becomes a valid character. $ groupingMatch = $ this -> getAttribute ( self :: GROUPING_USED ) ? '|(?P<grouping>\d++(,{1}\d+)++(\.\d*+)?)' : '' ; if ( preg_match ( "/^-?(?:\.\d++{$groupingMatch}|\d++(\.\d*+)?)/" , $ value , $ matches ) ) { $ value = $ matches [ 0 ] ; $ position = \ strlen ( $ value ) ; // value is not valid if grouping is used, but digits are not grouped in groups of three if ( $ error = isset ( $ matches [ 'grouping' ] ) && ! preg_match ( '/^-?(?:\d{1,3}+)?(?:(?:,\d{3})++|\d*+)(?:\.\d*+)?$/' , $ value ) ) { // the position on error is 0 for positive and 1 for negative numbers $ position = 0 === strpos ( $ value , '-' ) ? 1 : 0 ; } } else { $ error = true ; $ position = 0 ; } if ( $ error ) { IntlGlobals :: setError ( IntlGlobals :: U_PARSE_ERROR , 'Number parsing failed' ) ; $ this -> errorCode = IntlGlobals :: getErrorCode ( ) ; $ this -> errorMessage = IntlGlobals :: getErrorMessage ( ) ; return false ; } $ value = str_replace ( ',' , '' , $ value ) ; $ value = $ this -> convertValueDataType ( $ value , $ type ) ; // behave like the intl extension $ this -> resetError ( ) ; return $ value ; }
docstring: Parse a number.
  
  @param string $value    The value to parse
  @param int    $type     Type of the formatting, one of the format type constants. NumberFormatter::TYPE_DOUBLE by default.
  @param int    $position Offset to begin the parsing on return this value will hold the offset at which the parsing ended
  
  @return int|float|false The parsed value or false on error
  
  @see http://www.php.net/manual/en/numberformatter.parse.php
docstring_tokens: Parse a number .