A php algorithm calculation question. -Php Tutorial

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.