Solved

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

Posted on 2016-09-21
3
57 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 52

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 52

Expert Comment

by:Julian Hansen
ID: 41813470
You are welcome
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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.  …
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
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 dynamically set the form action using jQuery.

919 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now