3v4l.org

run code in 300+ PHP versions simultaneously
<?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; }

preferences:
52.86 ms | 402 KiB | 5 Q