我在验证数组输入为空时遇到问题价值例如
if(isset($_POST['submitted']))
{
if(empty($_POST['arrinput'])){
echo 'value not empty';
}
else {
echo 'value is empty';
}
}
<form enctype="multipart/form-data" action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']);?>" method="post">
<?php
$num = 0;
while($num < 2)
{?>
<input name="arrinput[]" type="text" /></div>
<?php $num++;
}
?>
<input type="submit" value="submiy" name="submitted"/>
</form>
有什么建议我该如何做到这一点吗?
我想明白了,谢谢你们的帮助
foreach( $_POST['arrinput'] as $key => $value )
{
if( empty( $value ) )
{
echo 'value is empaty';
}
}
你试过了吗?
<?php
if(!empty($_POST) && !empty($_POST['arrinput'])){
die("value found!");
}else{
die("value not found!");
}
?>
尝试此项检查$_POST["arrinput']
为空或不是
<?php
if(empty($_POST['arrinput'])){
echo 'value is empty';
}
else{
for($i=0;$i<=2;$i++){
echo '<input type="text" name="arrinput[]">';
}
}
?>