A php algorithm calculation question. Aaa = trim (request ("aaa "))
Bbb = trim (request ("bbb "))
Ccc = trim (request ("ccc "))
Ddd = trim (request ("ddd "))
Eee = trim (request ("eee "))
Fff = trim (request ("fff "))
Ggg = trim (request ("ggg "))
Hhh = trim (request ("hhh "))
..........
..........
?>
How can I use PHP to quickly calculate the number of non-null parameters received on this page ?, And echo the number and value of parameters one by one.
(Note: If these parameters contain commas or spaces, multiple parameters are required. Split and open with split, and echo them one by one)
There was already a good ASP writing method for this problem. because PHP is a beginner, I don't know how to rewrite it to PHP.
URL:Http://bbs.csdn.net/topics/391906200
Reply to discussion (solution)
$v){ if(trim($v)!=''){ echo $k .'='.$v.PHP_EOL; }}?>
$v){ if(trim($v)!=''){ echo $k .'='.$v.PHP_EOL; }}?>
Thanks to the moderator. please read the private message because I also want to have the loop function to process the data of each field in the form one by one, write the data to the database, and save these query conditions.
$v){ if(trim($v)!=''){ $v=str_replace(", ",",",$v); $v=str_replace(" ",",",$v); $arr = explode(',', $v); echo "key:". $k. "
"; foreach($arr as $kk=>$vv){ if(trim($vv)!=''){ echo $k.$kk.'--value:'.$vv.'
'; } } }}?>
$v){ if(trim($v)!=''){ $v=str_replace(", ",",",$v); $v=str_replace(" ",",",$v); $arr = explode(',', $v); echo "key:". $k. "
"; foreach($arr as $kk=>$vv){ if(trim($vv)!=''){ echo $k.$kk.'--value:'.$vv.'
'; } } }}?>
Like one !! The moderator is awesome.
@ AO xuexingfeng, boss. I asked another post. please answer me.