Blog

Latest updates from Cleonix Technologies
How to check the checkbox in PHP

PHP is a scripting language that is open source, interpreted and object-oriented, i.e. performed on the server-side. It is used for the development of web applications (a server-side application that produces vibrant page).

The main features of PHP are:

1.Performance: PHP written script executes those scripts published in other languages like JSP & ASP much quicker.

2.Open Source Software: PHP source code is accessible free of charge on the internet, you can develop all versions of PHP as required without paying any costs.

3.Platform Independent: PHP is accessible for the operating system WINDOWS, MAC, LINUX & UNIX. It is also possible to readily execute a PHP application created in one OS in another OS.

4.Compatibility: PHP is compatible with nearly all current local servers such as Apache, IIS, etc. Embedded: PHP code within HTML tags and scripts can be readily embedded.

Today we will discuss about how to check the checkbox in PHP:


<?php
$fruit = array( 1 => "Mango", 2 => "Apple", 3 => "Banana", 4 => "Cherry", 5 => "Orange");
$the_key = "Orange|Apple|Cherry"; // or whatever you want
$myrow = explode("|",$the_key);
$containsSearch1 = array_intersect( $fruit,$myrow);

foreach($fruit as $key=> $val)
{
if(in_array($val,$containsSearch1))
{
echo $val."<input type='checkbox' name='check_list[]' value='".$val."' checked='checked' /><br />";
 }
else
{ echo $val."<input type='checkbox' name='check_list[]' value='".$val."'  /><br />"; }
}
?>

About the author


0 comments

Leave a Reply

Your email address will not be published. Required fields are marked *