Home  >  Article  >  php教程  >  php怎么获取checkbox选中的值(实例)

php怎么获取checkbox选中的值(实例)

WBOY
WBOYOriginal
2016-06-13 09:39:511476browse

转自:http://blog.csdn.net/vip_linux/article/details/22975713

在php开发中,如何获取上一个页面中checkbox控件选中的值呢?并输出出来。

这里分享一个php获取复选框的值的例子,研究下php获取checkbox复选框中值 的方法。

  1.       
  2.    $music = $_POST['music'];  
  3.      
  4.    //取得所选中的checkbox的个数  
  5.      
  6.    $coun=count$music);  
  7.      
  8.    if ( is_array( $music ) ) {  
  9.      
  10.    echo ‘您选择的是 : ';  
  11.      
  12.    foreach ( $music as $key => $var )  
  13.      
  14.    echo '  ['.$var.']';  
  15.      
  16.    echo $key;  
  17.      
  18.    } // 脚本学堂 编辑整理  
  19.      
  20.    ?>  
  21.      
  22.    
      
  23.      
  24.    流行音乐
      
  25.      
  26.    乡村音乐
      
  27.      
  28.    古典音乐
      
  29.      
  30.      
  31.      
  32.    
Statement:
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