Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2016-09-21
3
Medium Priority
?
88 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 59

Accepted Solution

by:
Julian Hansen earned 2000 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 59

Expert Comment

by:Julian Hansen
ID: 41813470
You are welcome
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

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…
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
The viewer will learn how to count occurrences of each item in an array.
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…

722 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