sumar 2 variables que vienen de txt
Publicado por helpme (31 intervenciones) el 30/10/2017 16:10:53
Hola chicos alguien de ustedes sabe sumar 2 variables que vienen en archivos de texto el resultado no me da el valor nos mas imprime lo que se va sumar
cada valor viene de un archivo diferente
para el archivo1.txt tiene guardado el numero 1000
para el archivo2.txt trae el numero 500
cada valor viene de un archivo diferente
para el archivo1.txt tiene guardado el numero 1000
para el archivo2.txt trae el numero 500
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php
$file = fopen("archivo1.txt", "r") or exit("No hay causas de paro registradas");
//Output a line of the file until the end is reached
while(!feof($file))
{
echo fgets($file).
"";
}
$valor1 = fgets($file);
fflush($file);
fclose($file);
$file2 = fopen("archivo2.txt", "r") or exit("No hay causas de paro registradas");
//Output a line of the file until the end is reached
while(!feof($file2))
{
echo fgets($file2).
"";
}
$valor2 = fgets($file2);
$valor3= $valor2 + $valor1;
echo $valor3;
fflush($file2);
fclose($file2);
?>
Valora esta pregunta
0