Taylor Reed Taylor Reed - 7 months ago 10
PHP Question

PHP srlen outputs correct number but if statement returns false?

The following echo outputs 8 yet my if statement returns false? is_numeric works fine alone however I cannot figure out why strlen wont return true.

echo strlen($_POST['results']);
if (is_numeric($_POST['results']) && strlen($_POST['results'] == 8)) {

Answer

try this, your parens are messed-up :

if (is_numeric($_POST['results']) && ( strlen($_POST['results']) == 8) ) {