Home > Backend Development > PHP Tutorial > 关于数组循环判断问题

关于数组循环判断问题

WBOY
Release: 2016-06-23 14:23:57
Original
1010 people have browsed it

php 数组

有5个数组(目前只列3个组,获取的数组为5以内的几个数组):
array(
0=>array("oldyear" => "10","powerFlag" => "1","powerCredit" => "不良好"),
1=>array("oldyear" => "30","powerFlag" => "0","powerCredit" => "良好"),
2=>array("oldyear" => "80","powerFlag" => "1","powerCredit" => "良好")
.....
)
/*
//oldyear年龄
//powerFlag 是否签字
//powerFlag 信用情况
//信用情况:5位权利人中任何一个没有选择信用情况为良好,那么费用自动显示为2.0
//老年人:5位权利人只要有任何一个选择了老年人或未成年人(60为老年人),自动显示失败
//到场签字:5位权利人中只要有任何一个选择了不能到场签字(能到场为1,不能到场为0),自动显示失败

求高手指点,想了很久了,谢谢,不胜感激!

回复讨论(解决方案)

<?php$array = array(0=>array("oldyear" => "10","powerFlag" => "1","powerCredit" => "不良好"),1=>array("oldyear" => "30","powerFlag" => "0","powerCredit" => "良好"),2=>array("oldyear" => "80","powerFlag" => "1","powerCredit" => "良好"));$find=false;foreach($array as $row){ 	if($row["oldyear"]>60||$row["oldyear"]<18){		$find = true;//老年人:5位权利人只要有任何一个选择了老年人或未成年人(<18为未成年,>60为老年人),自动显示失败	}	if($row["powerFlag"]=='0'){		$find = true;//到场签字:5位权利人中只要有任何一个选择了不能到场签字(能到场为1,不能到场为0),自动显示失败	}	if($row["powerCredit"]=='不良好'){		$find = true;//信用情况:5位权利人中任何一个没有选择信用情况为良好	}}if($find===false){	echo '2.0';//自动显示为2.0}else{	//其他}?>
Copy after login

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template