Q:

Is there a shorthand way of checking if parameter exists and greater than zero?

I'm trying to check if a parameter is provided and passes a criteria, but seems verbose. This is what I have:
if (isset($request['limit']) && is_numeric($request['limit']) && (int)$request['limit'] > 0) {
    $post_params['posts_per_page'] = (int)$request['limit'];
}

I think it is safe, but is there a more concise way to achieve this while still remaining safe?

A:

You can use preg_match and see if the first character is [1-9] then any digits.
This will not allow zero values or empty or strings.  
You can add a ternary isset but shorter than that is out of my reach.
if(preg_match("/^[1-9]\d*$/", (isset($str) ? $str : 0))){
    // Something
}

