- strpos: documentation ( source)
- preg_match: documentation ( source)
- trim: documentation ( source)
- strtolower: documentation ( source)
<?php
$default = '10px';
$string = trim( strtolower( (string) '-20%x' ) );
if( strpos( $string, 'auto') !== false
|| strpos( $string, '0') !== false
|| preg_match( '/[+-]?[0-9]+.?([0-9]+)?(em|ex|%|px|cm|mm|in|pt|pc|ch|rem|vh|vw|vmin|vmax)$/', $string )
) {
echo $string;
} else {
echo $default;
}