PHP generating text only version of pages

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
horsleyaa
Forum Newbie
Posts: 20
Joined: Tue Mar 01, 2005 8:52 am
Location: Aylesbury, UK

PHP generating text only version of pages

Post by horsleyaa »

Hi,
Can PHP generate text only versions of pages?
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post by pickle »

I'm not sure what you mean. If you want it to dump a webpage with nothing but text, yes it can, you just output text. If you want it to generate a txt file with the contents of a webpage, it can do that to, but differently.

I'm a little confused as to what you mean because this seems like a really simple question. Do you have anything to elaborate on?
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
horsleyaa
Forum Newbie
Posts: 20
Joined: Tue Mar 01, 2005 8:52 am
Location: Aylesbury, UK

Post by horsleyaa »

I am developing a website that is going to benefit from being accessible.
What I need is for PHP to generate a text only version of a page, and then generate links at the bottom of the page to other text only versions. So basically, what I need is PHP to read a file and strip out anything that is not text and then display the text, with links at the bottom of the page to other pages that are also in this text-only format
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

You mean turn images off and everything... so the data transfer is reduced between client-server?

I don't think there's an actual function to do it, I'd PREFERABBLY wirte new text-only pages and just use them instead since the layout will go all funny if you just take the images out (Unless you carefully place a block div around each image).

Otherwise if you really want to strip out all images then you'd just run a preg_replace() with the appropriate regexp in it.

something like

Code: Select all

preg_replace('/<img src\=".+?">/', '', $page);
horsleyaa
Forum Newbie
Posts: 20
Joined: Tue Mar 01, 2005 8:52 am
Location: Aylesbury, UK

Post by horsleyaa »

thanks I was going to originally do this.
Can you look at the PHP and Accessibility post please?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

a templating system is still the way to go for this..
Post Reply