Internationalization NumberFormatter::parse
NumberFormatter::parse
numfmt_parse
(PHP 5 >= 5.3.0, PHP 7, PHP 8, PECL intl >= 1.0.0)
NumberFormatter::parse -- numfmt_parse — 숫자 구문 분석
설명
객체 지향 스타일 (method)
public NumberFormatter::parse(string $string
, int $type
= NumberFormatter::TYPE_DOUBLE, int &$offset
= null
): int|float|false
절차적 스타일
numfmt_parse(NumberFormatter $formatter
, string $string
, int $type
= NumberFormatter::TYPE_DOUBLE, int &$offset
= null
): int|float|false
현재 포맷터 규칙을 사용하여 문자열을 숫자로 구문 분석합니다.
매개변수
formatter
- NumberFormatter object.
string
- 숫자를 구문 분석할 문자열입니다.
type
- 사용할 서식 유형입니다. 기본적으로
NumberFormatter::TYPE_DOUBLE
이 사용됩니다. offset
- 구문 분석을 시작할 문자열의 오프셋입니다. 반환 시 이 값은 구문 분석이 종료된 오프셋을 유지합니다.
반환 값
구문 분석된 숫자의 값이거나 오류 시 false
입니다.
Examples
예제 #1 numfmt_parse() 예제
<?php
$fmt = numfmt_create( 'de_DE', NumberFormatter::DECIMAL );
$num = "1.234.567,891";
echo numfmt_parse($fmt, $num)."\n";
echo numfmt_parse($fmt, $num, NumberFormatter::TYPE_INT32)."\n";
?>
예제 #2 OO 예제
<?php
$fmt = new NumberFormatter( 'de_DE', NumberFormatter::DECIMAL );
$num = "1.234.567,891";
echo $fmt->parse($num)."\n";
echo $fmt->parse($num, NumberFormatter::TYPE_INT32)."\n";
?>
위의 예는 다음을 출력합니다.
1234567.891 1234567
기타
- numfmt_get_error_code() - 포맷터의 마지막 오류 코드 가져오기
- numfmt_format() - 숫자 서식 지정
- numfmt_parse_currency() - currency number 구문 분석