Laravel DOMPDF not generating HTML pdf file with dynamic data - php

hi guys, im trying to use barryvdh/laravel-dompdf, everything works fine except i cant load my data to the view to dynamically produce content, i keep getting 'Undefined variable: data'
here is my code:
$data =[
'fname'=>Input::get('efname'),
'lname'=>Input::get('elname'),
'dob'=>Input::get('edob'),
'reg_date'=>date('Y-m-d'),
'email'=>Input::get('eemailaddrs'),
'gender'=>Input::get('gender'),
'mobile'=>Input::get('emobile'),
'p_addrss'=>Input::get('epaddress'),
'c_addrss'=>Input::get('ecaddress'),
'quals'=>Input::get('quali'),
'pdfname'=>$pdfname,
'empId'=>Input::get('employeeId'),
];
return PDF::loadView('employee/generatepdf',$data)
->save(public_path().'/pdfs/'.$pdfname.'.pdf');
its going to pdf template page..But cant get the array values.
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
</head>
<body>
<img align="center" src="{{public_path()}}/assets/img/logo.png">
<table align="center" style="width:100%;margin-top:25px;">
<tr>
<td style="width:50%">Registration ID</td>
<td style="width:50%">:{{$data['empId']}}</td>
</tr>
<tr>
<td style="width:50%">Name</td>
<td style="width:50%">:{{$data['fname']}} {{$data['lname']}}</td>
</tr>
</table>
</body>
</html>
also not taking css rules into pdf file.
How can i solve this issue...?
Thanks

You can check if array contain data or not by :
$data =[
'fname'=>Input::get('efname'),
'lname'=>Input::get('elname'),
'dob'=>Input::get('edob'),
'reg_date'=>date('Y-m-d'),
'email'=>Input::get('eemailaddrs'),
'gender'=>Input::get('gender'),
'mobile'=>Input::get('emobile'),
'p_addrss'=>Input::get('epaddress'),
'c_addrss'=>Input::get('ecaddress'),
'quals'=>Input::get('quali'),
'pdfname'=>$pdfname,
'empId'=>Input::get('employeeId'),
];
dd($data);
return PDF::loadView('employee/generatepdf',$data)->save(public_path().'/pdfs/'.$pdfname.'.pdf');
just try it and you will find if your array contain data or not

Try like that,
Use an array as second argument for the view.
return PDF::loadView('employee/generatepdf',array('data'=>$data));

You need to pass $data variable using compact() function
return PDF::loadView('employee/generatepdf',compact('data'))
->save(public_path().'/pdfs/'.$pdfname.'.pdf');

Related

Convert a parse ini to array / objects

I'm using a program I made to scrape a file for text and parse the information into a ini file. I asked a question here earlier asking about parse_ini_file and why I could not use the indexes and someone gave me a way to loop through using this.
$ini_array = parse_ini_file("myfile.ini", true
foreach($ini_array as $key=>$value)
I then echo out the result echo ($value['Username']) . " "; and store it into the table. I have the table functioning link here, http://liveviewtest.byethost7.com/index.php but the plugin I'm using is not functioning as intended. The sorting does not work, and I'm wondering is it because the data type? http://www.datatables.net/manual/data tells you that the accepted data types are arrays, objects, and instances. My question is what would be the best way for me to convert this into one of these data types? I'm new to php / html so sorry if this is basic.
Php File http://pastebin.com/VRUHLdMQ
Ini File http://pastebin.com/yZsg16qA
Your table is being generated so PHP & Ini file are fine but HTML code you are generating is incorrect so either DataTable plugin or jQuery DOM parser is confused.
Please fix it and it should work fine.
Put jquery+datatables js/css into <head> section.
You use multiple <tbody> and you put </tr> after </tbody>
So basically you shoud put echo "</tbody>"; outside loop so
echo "<tbody>"; // <<< HERE
foreach ($ini_array as $key => $value) {
echo "<tr>";
for ($i = 0; $i < 12; $i++) {
echo "<td>";
echo ($value[$getstats[$i]]);
echo "</td>";
}
echo "</tr>";
}
echo "</tbody>"; // <<< HERE
I'm wondering is it because the data type? http://www.datatables.net/manual/data tells you that the accepted data types are arrays, objects, and instances.
No, your code its fine as manual says Data can be read from DOM. You need arrays/objects/instances if you create table straight from javascript.
See below:
DOM
When DataTables starts up, it will automatically check the table it is operating on for data that already exists inside it and use it for the table (note that it will throw this data away if you pass in data using data or ajax to get new data!). This is the simplest method of using DataTables - working with a regular HTML table.
Note that when using a DOM sourced table, DataTables will use arrays as the data source (see above) by default, although you could use the columns.data option to have it construct objects for the row data instead.
http://www.datatables.net/manual/data#DOM
Your table structure was not correct :
<html>
<head>
<!-- DataTables CSS -->
<link rel="stylesheet" type="text/css" href="http://liveviewtest.byethost7.com/DataTables-1.10.9/media/css/jquery.dataTables.css">
<!-- jQuery -->
<script type="text/javascript" src="http://liveviewtest.byethost7.com/DataTables-1.10.9/media/js/jquery.js"></script>
<!-- DataTables -->
<script type="text/javascript" src="http://liveviewtest.byethost7.com/DataTables-1.10.9/media/js/jquery.dataTables.js"></script>
<!--<link rel="stylesheet" type="text/css" href="http://liveviewtest.byethost7.com/style.css">-->
</head>
<body>
<script type="text/javascript">
$(document).ready(function () {
$('#mytable').DataTable();
});
</script>
<table id="mytable" border ="1" style="width:100%">
<thead>
<tr>
<th>Name</th>
<th>Kills</th>
<th>Death Total</th>
<th>Suicides</th>
<th>Bears</th>
<th>Wolves</th>
<th>Helicopter</th>
<th>Falling</th>
<th>Cold</th>
<th>Explosions</th>
<th>Barricade</th>
<th>Player Deaths</th>
</thead>
<tbody>
<tr>
<td>hpnotiq</td>
<td>0</td>
<td>1</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td><td>1</td><td>0</td><td>0</td></tr><tr><td>TacticalNuke735</td><td>1</td><td>12</td><td>12</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td></tr><tr><td>.buckisM</td><td>2</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td></tr><tr><td>Mrs Phluffy</td><td>0</td><td>4</td><td>1</td><td>1</td><td>0</td><td>1</td><td>1</td><td>0</td><td>0</td><td>0</td><td>0</td></tr><tr><td>My buddy's goin'a jail</td><td>6</td><td>134</td><td>126</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>8</td></tr><tr><td>marble</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td></tr><tr><td>Sir Joe</td><td>0</td><td>5</td><td>2</td><td>0</td><td>0</td><td>2</td><td>0</td><td>0</td><td>0</td><td>0</td><td>1</td></tr><tr><td>StryX</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td></tr><tr><td>Haroth</td><td>6</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td></tr><tr><td>Mr Sephy</td><td>2</td><td>6</td><td>4</td><td>0</td><td>0</td><td>1</td><td>0</td><td>1</td><td>0</td><td>0</td><td>0</td></tr><tr><td>Solblade531</td><td>2</td><td>4</td><td>2</td><td>0</td><td>0</td><td>1</td><td>0</td><td>0</td><td>0</td><td>0</td><td>1</td></tr><tr><td>Vavbro</td><td>3</td><td>14</td><td>8</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>6</td></tr><tr><td>Heisenberg</td><td>0</td><td>1</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>1</td></tr><tr><td>アッパーおっぱい</td><td>3</td><td>1</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>1</td><td>0</td><td>0</td></tr><tr><td>Tallsockboy</td><td>0</td><td>1</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>1</td></tr><tr><td>CHAPYSIX</td><td>1</td><td>2</td><td>1</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>1</td></tr><tr><td>Bik</td><td>0</td><td>1</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>1</td></tr><tr><td>Totes MiGoats</td><td>0</td><td>8</td><td>5</td><td>0</td><td>0</td><td>1</td><td>0</td><td>0</td><td>0</td><td>0</td><td>2</td></tr><tr><td>Blunted Out'cha Mind</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td></tr><tr><td>Jubby</td><td>0</td><td>1</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>1</td></tr><tr><td>That0neGuy</td><td>0</td><td>1</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>1</td></tr><tr><td>Nuclear</td><td>0</td><td>1</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>1</td></tr><tr><td>michaelswansey</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td></tr><tr><td>kapiowai</td><td>0</td><td>1</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>1</td></tr><tr><td>Kami</td><td>0</td><td>1</td><td>1</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td></tr><tr><td>Pika</td><td>0</td><td>1</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>1</td></tr><tr><td>WC Visuals</td><td>0</td><td>2</td><td>2</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td></tr><tr><td>STUDNASTY</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td></tr><tr><td>masternubb</td><td>0</td><td>2</td><td>0</td><td>0</td><td>1</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>1</td></tr><tr><td>Bignubbb</td><td>2</td><td>5</td><td>4</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>1</td></tr><tr><td>BAAABBYNUBB</td><td>0</td><td>1</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>1</td></tr><tr><td>Squirt</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td></tr><tr><td>Fluffy</td><td>0</td><td>1</td><td>1</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td></tr><tr><td>| Albatross</td><td>0</td><td>1</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>1</td></tr><tr><td>inmate #42069 weston gayboy</td><td>10</td><td>9</td><td>5</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>1</td><td>0</td><td>3</td></tr><tr><td>isaiahyo</td><td>0</td><td>8</td><td>3</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>2</td><td>3</td></tr><tr><td>Vortex</td><td>1</td><td>5</td><td>3</td><td>0</td><td>0</td><td>0</td><td>0</td><td>1</td><td>0</td><td>0</td><td>1</td></tr><tr><td>General Pro</td><td>0</td><td>1</td><td>1</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td></tr><tr><td>Ecchi Sketchy</td><td>0</td><td>1</td><td>1</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td></tr><tr><td>a e s t h e t i c</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td></tr><tr><td>TheS1mpleGuy2Know</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td></tr><tr><td>♥JaPierDoLe™</td><td>0</td><td>1</td><td>1</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td></tr><tr><td>JaidenV</td><td>1</td><td>2</td><td>1</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>1</td></tr><tr><td>FaceEatingTumor</td><td>0</td><td>1</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>1</td></tr><tr><td>Jfrisk</td><td>1</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td></tr><tr><td>Kilgore</td><td>0</td><td>1</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>1</td></tr><tr><td>chilmonik</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td></tr><tr><td>chrishawsome</td><td>0</td><td>1</td><td>0</td><td>0</td><td>1</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td></tr><tr><td>s4MPL3</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td></tr><tr><td>Dan Gleasak</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr></tbody>
</table>
</body>
</html>

PHP script mucks up copyright

I have written a PHP script that goes through and changes the HTML generated by Visual Page. (I know - it is a REALLY old program - but I like it.) Anyway, in each of these HTML web pages I'm working with I put in:
{copyright}
Where I want the copyright to show up. I did the following loop:
foreach( $file as $k1=>$v1 ){
if( preg_match("/\{copyright\}/i", $v1) ){
$file[$k1] = preg_replace( "/\{copyright\}/i", $copyright, $v1 );
}
}
This DID NOT WORK. I would echo out the $file[$k1] before and after the IF statement so I could see what was going on and PHP just wouldn't change the {copyright} to the copyright. The variable $copyright had something similar to:
<tr><td>Copyright 2007-NOW MyCompany. All rights reserved.</td></tr>
Now - here is the freaky thing: I put a BREAK after it did the preg_replace - and - it worked. So just changing the above to
foreach( $file as $k1=>$v1 ){
if( preg_match("/\{copyright\}/i", $v1) ){
$file[$k1] = preg_replace( "/\{copyright\}/i", $copyright, $v1 );
break;
}
}
Made it work. Does anyone have ANY kind of an idea why? I'm completely stumped by this.
Note: I thought I'd post what I had gotten the HTML down to.
<html>
<head>
<title>Test</title>
</head>
<body>
<table border='1' cellspacing='0' cellpadding='0'><tbody>
<tr><td>This is a test</td></tr>
{copyright}
</tbody></table>
</body>
</html>
That is what I boiled my test case down to.
Also note : I did get this to work. Don't know why I had to put in a BREAK statement and I put it in on a whim. My thinking went "Maybe there is something that is making it re-evaluate the string after the change? Let me try putting in a break statement." I did and - it worked. But I have no idea WHY it worked.
Maybe I'm missing something here but it doesn't seem like you need any regex's here. The str_replace function, http://php.net/str_replace, should work fine for this.
Example:
$string = "<html>
<head>
<title>Test</title>
</head>
<body>
<table border='1' cellspacing='0' cellpadding='0'><tbody>
<tr><td>This is a test</td></tr>
{copyright}
</tbody></table>
</body>
</html>";
$copyright = '<tr><td>Copyright 2007-NOW MyCompany. All rights reserved.</td></tr>';
echo str_replace('{copyright}', $copyright, $string);
Output:
<html>
<head>
<title>Test</title>
</head>
<body>
<table border='1' cellspacing='0' cellpadding='0'><tbody>
<tr><td>This is a test</td></tr>
<tr><td>Copyright 2007-NOW MyCompany. All rights reserved.</td></tr>
</tbody></table>
</body>
</html>
Demo: http://sandbox.onlinephpfunctions.com/code/f53b1a96f270e52392303d7dfb7c327372747d0b
Update per comment:
$string = "<html>
<head>
<title>Test</title>
</head>
<body>
<table border='1' cellspacing='0' cellpadding='0'><tbody>
<tr><td>This is a test</td></tr>
{copyright}
</tbody></table>
</body>
</html>";
$copyright = '<tr><td>Copyright 2007-NOW MyCompany. All rights reserved.</td></tr>';
foreach(explode("\n", $string) as $line) {
echo str_replace('{copyright}', $copyright, $line) . "\n";
}
Output:
<html>
<head>
<title>Test</title>
</head>
<body>
<table border='1' cellspacing='0' cellpadding='0'><tbody>
<tr><td>This is a test</td></tr>
<tr><td>Copyright 2007-NOW MyCompany. All rights reserved.</td></tr>
</tbody></table>
</body>
</html>
Although I am not yet sure exactly what is wrong - with the help of chris85 I no longer believe it is a PHP problem but instead is probably a hardware problem.
Chris posted to the PHP sandbox what I said I was using and it worked without a flaw. When I tried it ON the PHP sandbox (which means it used the sandbox's PHP interpreter) - it also worked without a problem.
Then I modified the program so it did the same thing but in two other ways. Thus, test #1 was just the single string, test #2 was the exploded string, and test #3 echoed out each individual string as it was modified.
On >MY< machine, the third method caused unexpected output to be generated. As stated though, the PHP sandbox computer did NOT have anything strange happen to it. Thus, this means that there is a hardware problem with my computer and not with PHP.
Sandbox link: http://sandbox.onlinephpfunctions.com/code/f34f57f6521cc6eebcc704b7c127974c0403834d
This question can now be closed.

displaying jp2 images stored in mysql database into web page

Here 'm trying for displaying jp2 image in a web page.
But I'm not able to converting it.
The simple code is like this
<html>
<body>
<table><tr><td>
<?php
echo ' PHOT:'.getPhotoFromMysqlDB();
?>
</td></tr></table>
</body>
</html?>
getPhotoFromMysqlDB() will return jp2 image.
*If i run above example the web page displaying junk like "bytecode" *
use below code:
<html>
<body>
<table>
<tr><td>
<img src="<?php echo ' PHOT:'.getPhotoFromMysqlDB();?>">
</td></tr>
</table>
</body>
</html>

Opening PHP statements

So I was just wondering if it was considered bad practice to open and close PHP statements, and let me explain what I mean. I know I can make variables at the beginning of my code but I like to group stuff together.I'm not sure if making one big PHP statement with all my variables is better / worse / same as opening and closing PHP statements similar to the example below.
<html>
<head></head> <---- HTML STUFF
<?php
(php stuff where connection to mysql db goes and other variables and errors)
?>
<body>
<html> <----- HTML stuff
<?php
(php stuff to call a specific table from DB)
?>
<html> <----- HTML stuff
<?php
(php stuff to call a specific table from DB)
?>
<html> <----- HTML stuff
<?php
(php stuff to call a specific table from DB)
?>
</body>
<html>
BTW the php variables I'm talking about are specific select statement from the DB.
ACTUAL CODE: or should select statements be at beg or sep file?
<table>
<tr>
<td align="left" width="200px">
Cover: Original Total
</td>
<td width="200px" align="center">
<?php
$original = "SELECT * FROM `comic_db`.`comic_db` WHERE comic_cover=\"original\"";
$orig_con = mysqli_query($comic_connect, $original);
$orig_total = mysqli_num_rows($orig_con);
echo $orig_total;
?>
</td>
</tr>
<tr>
<td width="200px" align="left">
Cover: Variants Total
</td>
<td width="200px" align="center">
<?php
$variants = "SELECT * FROM `comic_db`.`comic_db` WHERE comic_cover=\"variant\"";
$variant_con = mysqli_query($comic_connect, $variants);
$variant_total = mysqli_num_rows($variant_con);
echo $variant_total;
?>
</td>
</tr>
<tr>
<td align="left" width="200px">
Cover: Baby Totals
</td>
<td width="200px" align="center">
<?php
$baby = "SELECT * FROM `comic_db`.`comic_db` WHERE comic_cover=\"baby\"";
$baby_con = mysqli_query($comic_connect, $baby);
$baby_total = mysqli_num_rows($baby_con);
echo $baby_total;
?>
I'm assuming the repeated <html> tags in your example are just placeholders and would actually be <div>s and other elements making up the actual content of the page.
Your example is what's commonly called "spaghetti code" because it can quickly turn into an unmaintainable mess because you can't clearly see an overview of the HTML, nor can you see all the PHP code in one place.
The main thing to keep in mind is separating application logic (such as your database queries) from presentation (HTML and presentation logic like looping over an array to display it as an HTML list).
At the very least you'd want to put the main PHP code at the top of the file like you said, but it would be much better if it was in a separate file.
P.S. Any beginner book on PHP will discuss this in detail.

Convert HTML output into a plain text using php

I'm trying to convert my sample HTML output into a plain text but I don't know how. I use file_get_contents but the page which I'm trying to convert returns most like the same.
$raw = "http://localhost/guestbook/profiles.php";
$file_converted = file_get_contents($raw);
echo $file_converted;
profiles.php
<html>
<head>
<title>Profiles - GuestBook</title>
<link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<body>
<!-- Some Divs -->
<div id="profile-wrapper">
<h2>Profile</h2>
<table>
<tr>
<td>Name:</td><td> John Dela Cruz</td>
</tr>
<tr>
<td>Age:</td><td>15</td>
</tr>
<tr>
<td>Location:</td><td> SomewhereIn, Asia</td>
</tr>
</table>
</div>
</body>
</html>
Basically, I trying to echo out something like this (plain text, no styles)
Profile
Name: John Dela Cruz
Age: 15
Location: SomewhereIn, Asia
but i don't know how. :-( . Please help me guys , thank you in advance.
EDIT: Since i am only after of the content of the page, no matter if it's styled or just a plain text , is there a way to select only (see code below) using file_get_contents() ?
<h2>Profile</h2>
<table>
<tr>
<td>Name:</td><td> John Dela Cruz</td>
</tr>
<tr>
<td>Age:</td><td>15</td>
</tr>
<tr>
<td>Location:</td><td> SomewhereIn, Asia</td>
</tr>
</table>
Use php strip_tags
If strip_tags is not working for then maybe you can use regex to extract the info you want.
Try using PHP preg_match with /(<td>.*?<\/td>)/ as the pattern
Have a look at simplexml_load_file():
http://www.php.net/manual/en/function.simplexml-load-file.php
It will allow you to load the HTML data into an object (SimpleXMLElement) and traverse that object like a tree.
try to use PHP function strip_tags
try this one,
<?php
$data = file_get_contents("your_file");
preg_match_all('|<div[^>]*?>(.*?)</div>|si',$data, $result);
print_r($result[0][0]);
?>
I have try this one, and it seems work for me, for you too i hope
You can use the strip_tags php function for this. Browse through the comments in the php manual page of the strip_tags function to see how you can use this in a good way.

Categories