空输入字符串检查不起作用 [英] Empty input string checking not working

查看:92
本文介绍了空输入字符串检查不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个名为date的输入数组,返回11个值,其中只有6个设置了日期值。我的目标是确保数组中的所有剩余7个空值都未从数组中设置,只需使用设置的日期值重新编制索引。

尽管我的试验,重建索引的数组仍然返回2个空值和6个设置值,给我一个包含8个值的数组。我已经尝试过strlen,empty,isset甚至检查数组中的值是否为日期而没有多大用处,它仍然给出了相同的结果。非常欢迎您对这个问题的帮助,谢谢!



我尝试过的事情:



<?php 



$ date = $ _GET ['date'];




//不考虑任何空日期
($ i = 0; $ i< sizeof($ date) ; $ i ++){
if($ date [$ i] ==''){
unset($ date [$ i]);

}

$ date = array_values($ date);



}


//显示这个显示2个空值,6个设定值为
for($ i = 0; $ i< sizeof($ date); $ i ++){
echo< li>;
echo $ date [$ i];
echo< / li>;
}

?>

解决方案

date =


_GET [ '日期'];




//不考虑任何空日期


i = 0 ;

I am having an array of input named "date" returning 11 values of which only 6 are set with date values. My aim is to make sure all the remaining 7 empty values in the array are unset from the arrays, to be reindexed with only the set date values.
Despite my trials, the reindexed array still returns 2 empty values along with the 6 set ones, giving me an array with 8 values. I've tried strlen, empty, isset and even checking if the values in array are dates without much avail, it still gives me the same result. Your help on this issue will be greatly welcomed, Thanks !

What I have tried:

<?php



$date = $_GET['date'];




//To not take into account any empty date
for ($i = 0; $i < sizeof($date); $i++) {
    if ($date[$i] == '') {
        unset($date[$i]);
        
    }
    
    $date = array_values($date);
    
    
    
}


//displaying this shows 2 empty values with the 6 set values
for ($i = 0; $i < sizeof($date); $i++) {
    echo "<li>";
    echo $date[$i];
    echo "</li>";
}

?>

解决方案

date =


_GET['date']; //To not take into account any empty date for (


i = 0;


这篇关于空输入字符串检查不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆