mixkat
mixkat

Reputation: 3785

Check query result array's size

With the following code I can iterate through the elements of the returned array:

foreach ($GLOBALS['myDB']->getAssets($i['uId']) as $x)

But I can't figure out how to efficiently check the size of the returned array before entering the loop.

Any ideas?

Upvotes: 1

Views: 2313

Answers (2)

Prashant Singh
Prashant Singh

Reputation: 3793

You can use count to find out the length of an array

count($arrayName);

Upvotes: 1

rid
rid

Reputation: 63442

$assets = $GLOBALS['myDB']->getAssets($i['uId']);
$size = count($assets);

Upvotes: 4

Related Questions