/    Sign up×
Community /Pin to ProfileBookmark

Get part of another file

I want to get a part of the html from another file and read it into an array.
But how?

I have heard of that you can do it between comment tags, but i cant find anything on google :S

to post a comment
PHP

7 Comments(s)

Copy linkTweet thisAlerts:
@NightShift58Jan 25.2007 — First, to get the HTML file, you'll use [B]file_get_contents()[/B]. With that file, you'll filter in/out whatever segments you need, as you define it. When done, you can [B]explode()[/B] the remaining contents to an array.

If you use regular expressions, something like: [B]$bokeh = preg_magic()[/B] [NB: not a real function... yet...], then your content may already be in array form. You would then have to convert the results into whatever format you need, either looping through the resulting array or using an existing [B]array function[/B].
Copy linkTweet thisAlerts:
@alxlaauthorJan 25.2007 — Okey, how do i filter out my segments then?

And why should i explode it into an array?

I'm not so use with php, that's why i'm ascing this stupid question. But you gotta start somewhere ?
Copy linkTweet thisAlerts:
@NightShift58Jan 25.2007 — There's no quick answer to that. It depends on the data you want to parse/filter. If you provide examples, there are a couple of regular expression magicians who routinely look in...
Copy linkTweet thisAlerts:
@MrCoderJan 26.2007 — *Pulls a rabit out of a hat*
Copy linkTweet thisAlerts:
@alxlaauthorJan 26.2007 — Ok i can write a small "exmple":

File with info.;info.html:
[code=html]<HTML>
<body>
<!-- hello -->
Hello world
<!-- end hello -->
<!-- today-->
Today is a blue day
<!-- end today--><!-- yesterday-->
Yesterday was a green day
<!-- end yesterday--><!-- tommorrow-->
Tommorrow is a ornage day
<!-- end tomorow-->
</body>
</HTML>[/code]


And i want a file that fetches part of the file, and the output will be like:
[code=html]<HTML>
<body>

Today is a blue day

Tommorrow is a ornage day

</body>
</HTML>[/code]


And if you edit the first file the second will be updated automatic.
Copy linkTweet thisAlerts:
@MrCoderJan 26.2007 — Sounds very much like Dreamweaver templates?

Im pretty sure there tutorials on the net for striping dreamweaver templates (thats very much like your example).

I just found one..

http://www.cmarshall.net/MySoftware/DreamweaverTemplate/index.php

Download and examine the code, think its what your after?
Copy linkTweet thisAlerts:
@alxlaauthorJan 26.2007 — No it's not like that. I already have built up my site with ordinairy templatefiles.

What i want is to take out some information from a plain html file and put it in a variable in string format.
×

Success!

Help @alxla spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...