Linked Questions

643 votes
18 answers
1.3m views

players will either be empty or a comma separated list (or a single value). What is the easiest way to check if it's empty? I'm assuming I can do so as soon as I fetch the $gameresult array into $...
aslum's user avatar
  • 12.3k
393 votes
20 answers
495k views

I'd like to check if two arrays are equal. I mean: same size, same index, same values. How can I do that? Using !== as suggested by a user, I expect that the following would print enter if at least ...
markzzz's user avatar
  • 48.3k
141 votes
5 answers
242k views

Is it possible to get multiple inputs of the same name to post and then access them from PHP? The idea is this: I have a form that allows the entry of an indefinite number of physical addresses along ...
Adam's user avatar
  • 3,778
94 votes
5 answers
88k views

I'm looking to write a function that takes an array of pages/categories (from a flat database result) and generates an array of nested page/category items based on the parent ids. I would like to do ...
David Hemphill's user avatar
114 votes
3 answers
18k views

Does count() really count the all the elements of a PHP array, or is this value cached somewhere and just gets retrieved?
Dexter's user avatar
  • 3,122
19 votes
4 answers
11k views

Do you know why <?= count(false) ?> returns 1?
Jeremie Ges's user avatar
  • 2,763
10 votes
2 answers
6k views

This is mostly superficial but what's the best (faster performing, not personal preference or readability) way to check if an array is empty: count($arr) == 0 empty($arr) $arr === array() Other? My ...
Paystey's user avatar
  • 3,252
0 votes
3 answers
369 views

How do I check that a PHP array is not empty? // If $columns array is not empty... foreach ($columns as $column) { echo $column; }
MultiDev's user avatar
  • 10.7k
-2 votes
7 answers
86 views

I want to check if array is empty or not, i wrote few lines of code for it if(array() == $myArray){ echo "Array"; } or if(array() === $myArray){ echo "Array"; } I'm confused which one to use, ...
yo black's user avatar
  • 147
-2 votes
3 answers
144 views

I've var dumped my array: array(4) { [0]=> string(72) " 1 " [1]=> string(57) " 2 " [2]=> string(63) " › " [3]=> string(63) " » " } When I check: empty($myArray); It always says true. Why ...
panthro's user avatar
  • 24.2k