xref: /PHP-5.5/ext/filter/tests/049.phpt (revision 610c7fbe)
1--TEST--
2filter_var() and doubles with thousend separators
3--SKIPIF--
4<?php if (!extension_loaded("filter")) die("skip"); ?>
5--FILE--
6<?php
7$test = array(
8	'0'							=> 0.0,
9	'12345678900.1234567165'	=> 12345678900.1234567165,
10	'1,234,567,890.1234567165'	=> 1234567890.1234567165,
11	'-1,234,567,890.1234567165'	=> -1234567890.1234567165,
12	'1234,567,890.1234567165'	=> false,
13	'1,234,567,89.1234567165'	=> false,
14	'1,234,567,8900.1234567165'	=> false,
15	'1.234.567.890.1234567165'	=> false,
16	'1,234,567,8900.123,456'	=> false,
17);
18foreach ($test as $src => $dst) {
19	$out = filter_var($src, FILTER_VALIDATE_FLOAT, array("flags"=>FILTER_FLAG_ALLOW_THOUSAND));
20	if ($dst !== $out) {
21		if ($out === false) {
22			echo "$src -> false != $dst\n";
23		} elseif ($dst === false) {
24			echo "$src -> $out != false\n";
25		} else {
26			echo "$src -> $out != $dst\n";
27		}
28	}
29}
30
31echo "Ok\n";
32?>
33--EXPECT--
34Ok
35