Home  >  Article  >  Backend Development  >  How to get the selected value of checkbox in php (example)_PHP tutorial

How to get the selected value of checkbox in php (example)_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:34:361922browse

Reprinted from: http://blog.csdn.net/vip_linux/article/details/22975713

In PHP development, how to get the selected value of the checkbox control in the previous page? and output it.

Here is an example of getting the value of a checkbox in PHP. Let’s study the method of getting the value of a checkbox in PHP.

  1.  $music = $_POST['music'];
  2.  
  3. //Get the number of selected checkboxes
  4.  
  5. $coun=count($music);
  6.  
  7. if ( is_array( $music) ) {
  8.  
  9. echo ‘You have selected: ';
  10.  
  11. foreach ( $music as $key => $var )
  12.  
  13. echo ' ['.$var. ']';
  14.  
  15. echo $key;
  16.  
  17. } // Scripting School Editing
  18.  
  19. ?>
  20.  
  21.  
  22. pop music
  23.  
  24. Country Music
  25.  
  26. Classical Music
  27.  
  28.  

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/749823.htmlTechArticleReprinted from: http://blog.csdn.net/vip_linux/article/details/22975713 In PHP development, How to get the selected value of the checkbox control on the previous page? and output it. Share one here...
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