Hello!
Tell me, please, how can I check the array for empty values?
For example,
$test = array(''); If the values of the array will contain a different number of spaces, then how to check and exclude keys with empty values?
Thank!
Hello!
Tell me, please, how can I check the array for empty values?
For example,
$test = array(''); If the values of the array will contain a different number of spaces, then how to check and exclude keys with empty values?
Thank!
Well, you can array_filter($array) call the function array_filter($array) without a callback function and it will clear the array of null,false,''
like this
foreach ($playerlist as $key => $value) { if (empty($value)) { //проверяем если пустой unset($playerlist[$key]); } } if the whole array is empty
if (empty($playerlist)) { //empty array } The array_filter function can help
array_filter($test, 'remove_empty'); function remove_empty($v) { return trim($v) == $v; } Source: https://ru.stackoverflow.com/questions/610408/
All Articles