PHP-s forráskódot
mutat /
elrejt
<?php
//DOCTYPE előtt
$filename = "fbi/fbitagok/tag-1.php";
//a szükséges INPUT mezők száma
$utolso = isset($_POST["utolso"]) ? $_POST["utolso"] : 2;
$input_szam = isset($_POST["mezoszam"]) ? $_POST["mezoszam"] : $utolso;
if(!file_exists($filename))
{ file_put_contents($filename, ""); }
if(isset($_POST["mentes"]))
{
$n = 1;
$new_content = '';
while($n <= $utolso)
{
$plus_content = $_POST["tag-".$n];
if($n != $utolso)
{ $new_content = $new_content.$plus_content."|"; }
else
{ $new_content = $new_content.$plus_content; }
$n = $n + 1;
}
file_put_contents($filename, $new_content);
}
//BODY-ban
<h1>Egy fájlban több adat tárolása és kiolvasása.(HendRoox)</h1>
<h3>INPUT mezők választható száma</h3>
<form method="post" action="?m=<?php echo $input_szam; ?>">
<input type="radio" name="mezoszam" value="2"
<?php if($input_szam==2) { echo 'checked="checked"'; } ?> /> kettő
<input type="radio" name="mezoszam" value="4"
<?php if($input_szam==4) { echo 'checked="checked"'; } ?> /> négy
<input type="radio" name="mezoszam" value="8"
<?php if($input_szam==8) { echo 'checked="checked"'; } ?> /> nyolc
<input type="radio" name="mezoszam" value="10"
<?php if($input_szam==10) { echo 'checked="checked"'; } ?> /> tíz<br />
<input type="submit" name="valaszt" value="Választás" />
</form>
<hr class="rovid" />
<h3>A választott darabszámu INPUT mező</h3>
<form method="post" action="">
<?php
$n = 1;
while($n <= $input_szam)
{ echo 'Tag- '.$n.': <input type="text" size="20" name="tag-'.$n.
'" value="" /><br /><br />'; $n = $n + 1; }
?>
<input type="hidden" name="utolso" value="<?php echo $input_szam; ?>" />
<input type="submit" name="mentes" value="Adatok mentése" />
</form>
<h3>Utoljára elküldött adatok</h3>
<?php
$n = 0;
$tag = file_get_contents("fbi/fbitagok/tag-1.php");
$inputs = explode("|", $tag);
echo '<div style="width:400px;margin:0 auto;padding:5px;text-align:left;border:1px solid gray;">';
for($i=0;$i<count($inputs);$i++)
{
if($inputs[$i] != "")
{ echo 'A tag-1.php "<b>input'.($i+1).'</b>" tartalma <b>'.$inputs[$i].'</b><br />'; }
else
{ echo 'A tag-1.php "<b>input'.($i+1).'</b>" tartalma <b>ÜRES VOLT KÜLDÉSKOR</b><br />'; }
}
echo '</div>';
?>
PHP-s forráskódot
mutat /
elrejt
<?php
echo '"range(0, 12)": <br />';
foreach (range(0, 12) as $number) {
echo $number.', ';
}
echo '<br />"range(0, 100, 10)": <br />';
foreach (range(0, 100, 10) as $number) {
echo $number.', ';
}
echo '<br />"range(\'c\', \'l\')": <br />';
foreach (range('c', 'l') as $letter) {
echo $letter.', ';
}
echo '<br />"range(\'l\', \'c\')": <br />';
foreach (range('l', 'c') as $letter) {
echo $letter.', ';
}
?>