note 59929 added to function.count

From: Date: Tue, 20 Dec 2005 13:59:58 +0000
Subject: note 59929 added to function.count
Groups: php.notes 
Request: Send a blank email to php-notes+get-100465@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 ?> ---- Manual Page -- http://www.php.net/manual/en/function.count.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+59929 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+59929&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+59929&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+59929&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+59929&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+59929&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+59929&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+59929&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+59929&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#100465) next »