Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update TableSorting.php #1

Merged
merged 1 commit into from
Oct 14, 2018
Merged

Update TableSorting.php #1

merged 1 commit into from
Oct 14, 2018

Conversation

WinterSilence
Copy link
Contributor

No description provided.

@TsSaltan
Copy link
Owner

Если честно, не помню, почему пришлось использовать регулярки, там какой-то формат данных не прокатывал через is_numeric

@WinterSilence
Copy link
Contributor Author

@TsSaltan судя по коду твой метод такой же кривой как и тот что в jphp, пример из описания php фунции:

$tests = array(
    "42",
    1337,
    0x539,
    02471,
    0b10100111001,
    1337e0,
    "not numeric",
    array(),
    9.1,
    '...',
    '.1.'
);
foreach ($tests as $element) {
    if (is_numeric($element)) {
        echo "'{$element}' - число", PHP_EOL;
    } else {
        echo "'{$element}' - НЕ число", PHP_EOL;
    }
}
/*
Результат выполнения данного примера:
'42' - число
'1337' - число
'1337' - число
'1337' - число
'1337' - число
'1337' - число
'not numeric' - НЕ число
'Array' - НЕ число
'9.1' - число
'...' - НЕ число
'.1.' - НЕ число
*/

Твой вариант даже хуже jphp т.к. TableSorting::isNumber('...') = true, TableSorting::isNumber('.0.') = true

@TsSaltan TsSaltan merged commit dae25c4 into TsSaltan:master Oct 14, 2018
@TsSaltan
Copy link
Owner

Для моей задачи нужно было именно такое поведение, всякие 0....1 должны были сравниваться с другими как числа, а не строки, но для общего пользования is_numeric всё же корректнее работает

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants