note 90177 added to function.count

From: Date: Thu, 09 Apr 2009 03:37:17 +0000
Subject: note 90177 added to function.count
Groups: php.notes 
Request: Send a blank email to php-notes+get-152987@lists.php.net to get a copy of this message
php 5.3 adds support to count a multi-dimensional array without the need for recursion, another option which would be fast is with session variables. While you are building the array original from your database query a looping function builds the dimensions and you will need to obtain the number of rows with something similar to the following: $rowcount = mysqli_num_rows($myquery); On the next line: $_SESSION['rowcount'] = $rowcount; then on the page needing the rowcount information do something like: $rowcount = $_SESSION['rowcount']; unset($_SESSION['rowcount']); Then your $rowcount is easily available and the session memory usage has been released. Granted if you are not performing some kind of loop to build the multi-dimensional array first you will not be able to take advantage of this method. Enjoy. ---- Server IP: 209.41.74.194 Probable Submitter: 98.100.167.1 ---- Manual Page -- http://www.php.net/manual/en/function.count.php Edit -- https://master.php.net/note/edit/90177 Del: integrated -- https://master.php.net/note/delete/90177/integrated Del: useless -- https://master.php.net/note/delete/90177/useless Del: bad code -- https://master.php.net/note/delete/90177/bad+code Del: spam -- https://master.php.net/note/delete/90177/spam Del: non-english -- https://master.php.net/note/delete/90177/non-english Del: in docs -- https://master.php.net/note/delete/90177/in+docs Del: other reasons-- https://master.php.net/note/delete/90177 Reject -- https://master.php.net/note/reject/90177 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#152987) next »