Jump to content

Array count with a twist?


dinoroger

Recommended Posts

So I want to have a named array with rows of information from a database but also include some always present data in the array.

 

For example the array might look like this:

$mydata['note'] = 'hello';

$mydata['other'] = 'test';

$mydata[0]['name'] = 'John Doe';

$mydata[0]['age'] = '32';

$mydata[1]['name'] = 'Jane Doe';

$mydata[1]['age'] = '37';

 

Currently when I use count or sizeof command I get the answer of 4. Is there any command that would return an answer of 2 and ignore the non numerical row values of the array highlighted in blue?

 

Some information behind this request. I am writing a database return function where a typical named array is returned started at [0] with all the row columns of data. I want to have some static information such as query errors, keys, affected rows, and some other information in the array at the base. I can store the number of rows returned as base data also but was hoping for another count command or count option that would only count the numerical part of the array and ignore the named parts.

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.