Solved

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

Posted on 2016-09-21
3
49 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 51

Accepted Solution

by:
Julian Hansen earned 500 total points
Comment Utility
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
Comment Utility
Perfect!

Thanks, Julian!
0
 
LVL 51

Expert Comment

by:Julian Hansen
Comment Utility
You are welcome
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Consider the following scenario: You are working on a website and make something great - something that lets the server work with information submitted by your users. This could be anything, from a simple guestbook to a e-Money solution. But what…
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

771 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

13 Experts available now in Live!

Get 1:1 Help Now