LMSouq
php-dev Open

Check whether an array is empty

GB
gbhall
1 month ago
3 views
Problem Description
I have the following code <?php $error = array(); $error['something'] = false; $error['somethingelse'] = false; if (!empty($error)) { echo 'Error'; } else { echo 'No errors'; } ?> However, `empty($error)` still returns `true`, even though nothing is set. What's not right?

AI-Generated Solution

Powered by LMSouq AI · GPT-4.1-mini

✓ Solution Ready
Analyzing problem and generating solution…
Was this solution helpful?
Back to Knowledge Base