- var_dump: documentation ( source)
- abs: documentation ( source)
<?php
function absint( $maybeint ) {
return abs( (int) $maybeint );
}
$test = [
'10',
' 10',
'10 ',
' 10 ',
];
foreach($test as $value) {
var_dump(absint($value));
}