I have a page that loads and creates an empty array:
$_SESSION['selectedItemIDs'] = array();
If the user hasn't added any selections that get stored in the array I then check the array and branch accordingly, but there appears to be some error in my logic/syntax that is failing here.
Here's where I test if the $_SESSION['selectedItemIDs'] is set but empty:
if (isset($_SESSION['selectedItemIDs']) && $_SESSION['selectedItemIDs'] !== '') {
// update the selections in a database
} else {
// nothing selection so just record this in a variable
$selectedItems = 'no selected items were made';
}
When testing this with no selections if I print the $_SESSION['selectedItemIDs'] array I get this:
[selectedItemIDs] => Array
(
)
however the $selectedItems variable is not being set - it's evaluating the if test as true when I would expect it to be false, but I'm obviously misunderstanding something here.
array()is obviously not identical to''…