note 1065 modified in function.count by vrana

From: Date: Tue, 17 Aug 2004 14:55:46 +0000
Subject: note 1065 modified in function.count by vrana
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-79802@lists.php.net to get a copy of this message
Be careful of recasting your variables, especially with database array returns: <?php $res = mysql_query("select * from blah") // a query that returns an empty set $row = mysql_fetch_array($res); // get's 0 since there's no return echo count($row); // echos 1 - since $row is not an array echo $row[0]; // echos "", but casts $row as an array? echo count($row); // echos 0 now ?> --was-- Be careful of recasting your variables, especially with database array returns: $res = mysql_query("select * from blah") // a query that returns an empty set $row = mysql_fetch_array($res); // get's 0 since there's no return echo count($row); // echos 1 - since $row is not an array echo $row[0]; // echos "", but casts $row as an array? echo count($row); // echos 0 now http://php.net/manual/en/function.count.php

« previous php.notes (#79802) next »