Solved

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

Posted on 2016-09-21
3
86 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 58

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 58

Expert Comment

by:Julian Hansen
ID: 41813470
You are welcome
0

Featured Post

Want Experts Exchange at your fingertips?

With Experts Exchange’s latest app release, you can now experience our most recent features, updates, and the same community interface while on-the-go. Download our latest app release at the Android or Apple stores today!

Question has a verified solution.

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

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
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…

627 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