Parsing results from a different php page

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
andym01480
Forum Contributor
Posts: 390
Joined: Wed Apr 19, 2006 5:01 pm

Parsing results from a different php page

Post by andym01480 »

I have a script that is generating a pdf file using fpdf. It needs to grab the html output from a different script called listing.php, strip out the html and reformat it to insert into the pdf. Bizarrely I think i can work out the processing easily enough, but the grey matter has gone blank on grabbing it from the output of listing.php in the first place!

I have a nudging feeling that a :oops: will be in order after the first reply!
SpiderMonkey
Forum Commoner
Posts: 85
Joined: Fri May 05, 2006 4:48 am

Post by SpiderMonkey »

I recall a long time ago I did HTML requests from php.

I'll look up what I did and post it if noone else knows this.

edit: Hmmm, apparantly last time I did in ASP not php :oops:

Regardless, I think this is what you are looking for:

http://uk2.php.net/manual/en/function.fsockopen.php

Connect to the server hosting the php page and you can treat its output like a file.
User avatar
andym01480
Forum Contributor
Posts: 390
Joined: Wed Apr 19, 2006 5:01 pm

Post by andym01480 »

On the support forum for the calendar software I was using, it has been suggested to use ob_start and ob_get_contents

Code: Select all

<?php

ob_start();
include ("listing.php");
$output = ob_get_contents();
ob_end_clean();

//process $output blah blah
?>
Will give it a try and come back!
User avatar
andym01480
Forum Contributor
Posts: 390
Joined: Wed Apr 19, 2006 5:01 pm

[SOLVED] Parsing results from a different php page

Post by andym01480 »

Hallelujah! It works, now to work out how to process it!
Post Reply