HTML Table From Php Array Output
Posted: Wed Sep 28, 2011 10:31 am
Hello PHP Gurus,
I'm new to php and I'm trying to format the output of a php array into the form of an HTML table format. The Php program calls on a perl script and just takes the output of the perl program and outputs it into the browser. The problem is that I've been having troubles trying to iterate through the php array and formatting the output into an html table. The original output of the program comes out as the following sample:
MCC MNC COUNTRY CARRIER POSTPAID CAMEL DATA
----------- ----------- ------------ ------------ -------- -------
20201 Greece Cosmote Launched No N
20205 Greece Vodafone Launched No Y
20210 Greece Wind_TIM Launched Yes N
20404 Netherland Vodafone Launched No N
Below is the php program that calls the perl program and stores the output above into a php variable and then attempts to format into an HTML table. Can somebody assist me? I've been looking everywhere online but i've had no success in trying to successfully execute what i'm attempting. Is this possible?
I'm new to php and I'm trying to format the output of a php array into the form of an HTML table format. The Php program calls on a perl script and just takes the output of the perl program and outputs it into the browser. The problem is that I've been having troubles trying to iterate through the php array and formatting the output into an html table. The original output of the program comes out as the following sample:
MCC MNC COUNTRY CARRIER POSTPAID CAMEL DATA
----------- ----------- ------------ ------------ -------- -------
20201 Greece Cosmote Launched No N
20205 Greece Vodafone Launched No Y
20210 Greece Wind_TIM Launched Yes N
20404 Netherland Vodafone Launched No N
Below is the php program that calls the perl program and stores the output above into a php variable and then attempts to format into an HTML table. Can somebody assist me? I've been looking everywhere online but i've had no success in trying to successfully execute what i'm attempting. Is this possible?
Code: Select all
<?php
function PrintRoaming() {
include 'config.inc' ;
ini_set('display_errors', '1');
error_reporting(E_ALL);
ini_set('max_execution_time', 300); //300 seconds = 5 minutes
$output = array(`$PERL $BASEPATH/PrintRoaming.pl`);
echo "<table border='1'>";
for ($i=0; $i < count($output); $i++){
echo "<tr><td>$output[$i]</td></tr>";
}
echo "</table>";
}
PrintRoaming();
?>