Created
March 9, 2017 09:57
-
-
Save daylik/15c35e67cf09b7f556a49971d3121e50 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$currentCatId = '1,2'; | |
function is_var_ok( $var, $reg ){ | |
if(isset($reg)){ | |
$is_filter_ok = $reg; | |
} else { | |
$is_filter_ok = '#^[0-9,\s]+$#'; //проверка на вхождения в струку только 0-9 запятой и пробелов | |
} | |
if( isset($var) && preg_match($is_filter_ok, $var) && $var != 0 && $var != '' ){ | |
return true; | |
} else { | |
return false; | |
} | |
} | |
//do it | |
if( is_var_ok($currentCatId, '#^[0-9,\s]+$#') ){ | |
echo $currentCatId; | |
} else { | |
echo 'false'; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment