Untitled
user_8607526207
php
a year ago
694 B
0
Indexable
Never
<?php // Doc du lieu tu file txt $myfile = fopen("list.txt", "r"); $content = fread($myfile,filesize("list.txt")); $lines = explode(" ",$content); $listPoint=array(); $name = $email = ""; $name = $_POST["name"]; if($_SERVER["REQUEST_METHOD"] == "POST"){ $lines = explode(" ",$name); foreach($lines as $Curline){ $Point = (int)$Curline; array_push($listPoint, $Point); } $se=0; foreach($listPoint as $CurPoint){ $se = $se + $CurPoint; if($se < array_sum($listPoint)){ $myfile = fopen("result.txt", "a"); fwrite($myfile, (string)$se .' ' ); } else{ fopen("result.txt", "a"); fwrite($myfile, (string)$se); } } fclose($myfile); } header('Location: index.html'); ?>