Skip to content

Instantly share code, notes, and snippets.

@epynic
Last active December 21, 2015 06:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save epynic/6267085 to your computer and use it in GitHub Desktop.
Save epynic/6267085 to your computer and use it in GitHub Desktop.
LIVE AT
http://epynic.asia/vacation/1.php
http://epynic.asia/vacation/2.php
<form action="1.php" method="post">
<input type ="text" name="number" placeholder="Enter Number !" >
<button type="submit" class="btn">Submit</button>
</form>
<?php
if (isset($_POST['number'])){
$n = $_POST['number'];
if (!is_numeric($n) ){
die('Numbers Crazy !');}
echo '<table class="table">
<thead>
<tr>
<th>Number</th>
<th>Divisible By</th>
<th>Output</th>
</tr>
</thead>';
$i = 1;
while($i < $n) {
echo '<tr><td>'.$i.'</td>';
if($i % 5 == 0 && $i % 3 == 0){
echo '<td> 3 & 5 </td><td>Whazaa</td></tr>';
}elseif($i% 5 ==0){
echo '<td> 5 </td><td>Hop</td></tr>';
}elseif($i% 3 ==0){
echo '<td> 3 </td><td>Hip</td></tr>';
}else{
echo '<td> NA </td><td>'.$i.'</td></tr>';
}
$i++;
}
}
?>
</div>
LIVE AT
http://epynic.asia/vacation/1.php
http://epynic.asia/vacation/2.php
<form enctype="multipart/form-data" action="2.php" method="POST">
Choose a file to upload: <input name="uploadedfile" type="file" /><br />
<input type="submit" value="Upload File" />
</form>
<?php
if ( isset($_FILES['uploadedfile']['tmp_name']) ){
$new_file_name = "1.txt";
move_uploaded_file($_FILES['uploadedfile']['tmp_name'], '/home/u500091294/public_html/vacation/'.$new_file_name);
if (fopen("1.txt", "r")){
$f = fopen("1.txt", "r");
while (!feof($f)) {
$count = explode(" ",fgets($f));
}
$c = array_count_values($count);
echo '<table class ="table"><tr><td>Number</td><td>Frequency</td></tr>';
foreach($c as $splits=>$s){
echo '<tr> <td>'.$splits.'</td><td>'.$s.'</td></tr>';
}
echo '</table>';
fclose($f);
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment