Solved

How can I test for one "row" and values in every "column" in this array?

Posted on 2016-09-21
3
70 Views
Last Modified: 2016-09-24
The app that I'm working on returns and multi-dimensional, associative array that looks like this:

screenshot
Now, that's what you're seeing in MSSQL Studio. On the PHP side, I've got this going on:

$accountactive = Accounts::checkStatementWorthy($accountid);
	$count_accountactive=count($accountactive);
	echo "number of worthy accounts: ";
	echo $count_accountactive;
	echo "<br><br>";

Open in new window


When I do "count($accountactive)," I get 42. 42 is the number of "columns" in the array, which you can see in the screenshot (AccountID, PracticeID, etc).

What I want to test is the fact that I've got more than just a "truth-y" array. I want to know that I've got one row with values in most, if not all, of the columns. And forgive me for my verbiage. I realize that with arrays, you're looking at indices etc., but, for the sake of clarity, I wanted to use spreadsheet-esque type terminology.

Even if I did a foreach and tested for the presence of $I[AccountID], that would could work, I suppose. But I wanted the best and most elegant approach.

What do you think?
0
Comment
Question by:brucegust
  • 2
3 Comments
 
LVL 55

Accepted Solution

by:
Julian Hansen earned 500 total points
ID: 41810210
If (!empty($accountactive) && is_array($accountactive)) {
   echo "You have something in your array ...";
}
else {
   echo "I got nothing!";
}

Open in new window

0
 

Author Closing Comment

by:brucegust
ID: 41813130
Perfect!

Thanks, Julian!
0
 
LVL 55

Expert Comment

by:Julian Hansen
ID: 41813470
You are welcome
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to count occurrences of each item in an array.

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question