Saturday, July 26, 2008

PHP Filesystems - fgets, feof, fclose

<?
$phpfilesystem = fopen("php latest technologies.txt", "r");//read only

if ($phpfilesystem) {
while (!feof($phpfilesystem)) {
$buffer = fgets($phpfilesystem, 4096);
echo $buffer;
}
fclose($phpfilesystem);
}
?>

PHP Filesystem - fopen

<?
$phpfilesystem = fopen("kuselan movie.txt", "r"); //read only
$phpfiles = fopen("rajini robo.txt", "w"); //write only file pointer at beginning
$phpexamples = fopen("rajini robo.txt", "a"); //write only file pointer at end
?>

Thursday, July 17, 2008

PHP - WHILE LOOP

$counter = 1;
while ( $counter <= 10 ) {
echo "Hello world";
$counter = $counter + 1;
}

PHP - FOR LOOP

for ( $counter = 0; $counter <= 10; $counter += 1) {
echo "Hello world";
}

Tuesday, July 15, 2008

PHP Radio button array example

HTML Code:
1 <input type="radio" name="Seenivasagaperumal" value="1"/>
2 <input type="radio" name="Seenivasagaperumal" value="2"/>
3 <input type="radio" name="Seenivasagaperumal" value="3"/>
4 <input type="radio" name="Seenivasagaperumal" value="4"/>

PHP code:
if(isset($_POST['Submit'])){
$eric = $_POST['Seenivasagaperumal'];
}

Thursday, July 3, 2008

PHP array selected item delete

<?
$tagCollection = array("AJAX", "Analytics", "CSS", "Javascript", "JoshSchumacher.com", "PHP", "Prototype", "Web 2.0");
function strMatch($val)
{
$query = isset($_REQUEST['sel']) ? $_REQUEST['sel'] : '';
return (stripos($val, $query) !== false);
}
$tags = array_filter($tagCollection, "strMatch");
$key = key($tags);
unset($tagCollection[$key]);
print_r($tagCollection);
?>