Let's say, for example, you wanted to get the contents of the sidebar of [url=http://www.ryanbrill.com]Ryan Brill[/url]'s site (Sorry, Pyro)...[code=php]<?php // Get file contents into a string $file = implode('', file('http://www.ryanbrill.com/')); // Seperate string into array- [0] is before '<div id="subnav">', [1] is after. $file = explode('<div id="subnav">', $file); // Since $file is an array, and [1] == after '<div id="subnav">', split that part by </div> $file = explode('</div>', $file[1]); // Now you have all the content between <div id="subnav"> and </div> in a variable. $file = $file[0]; ?>[/code]Does that give you any ideas of what to do?
@Ben_RogersNov 27.2004 — #[i]Originally posted by tanfwc [/i]
[B]One question, why must use implode ? [/B][/QUOTE] file() returns an array- I don't know of a function like it that doesn't- and implode makes an array into a string.
@Ben_RogersNov 27.2004 — #[i]Originally posted by tanfwc [/i]
[B]Oh that's mean must change it to string before we can make changes to it right? [/B][/QUOTE] That's mean? I don't understand- do you want it to be a line by line array? ?
@jinkasNov 29.2004 — #just for the record, file_get_contents($file) will read the contents of $file into a string...it's identical to (but faster than) using file() and implode() together
@Ben_RogersNov 29.2004 — #[i]Originally posted by jinkas [/i]
[B]just for the record, file_get_contents($file) will read the contents of $file into a string...it's identical to (but faster than) using file() and implode() together [/B][/QUOTE]*Looks at manual page for file_get_contents()* O_o Didn't know you could use it for external files, thought it didn't support 'em. Yes, that is the better function to use.