<?php
$values = array(
0,
1,
'1',
1.00,
1.01,
2.33,
3.445
3.45
);
foreach($values as $value) {
$regexp = '/^(-)?[0-9]+\.[0-9][0-9]?$/';
preg_match($regexp, $value, $matches);
var_dump($matches);
}
- Output for 5.4.0 - 5.4.28
- Parse error: syntax error, unexpected '3.45' (T_DNUMBER), expecting ')' in /in/4NsZE on line 10
Process exited with code 255. - Output for 5.3.0 - 5.3.28
- Parse error: syntax error, unexpected T_DNUMBER, expecting ')' in /in/4NsZE on line 10
Process exited with code 255.
preferences:
186.43 ms | 1395 KiB | 65 Q