dinoroger Posted February 4, 2017 Share Posted February 4, 2017 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. Quote Link to comment Share on other sites More sharing options...
Barand Posted February 4, 2017 Share Posted February 4, 2017 You could rearrange the array structure, thus $mydata['note'] = 'hello'; $mydata['other'] = 'test'; $mydata['data'][0]['name'] = 'John Doe'; $mydata['data'][0]['age'] = '32'; $mydata['data'][1]['name'] = 'Jane Doe'; $mydata['data'][1]['age'] = '37'; Now you can count($mydata['data']) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.