| re: Array problems
Hello Rondell,
perhaps I've explained my aim imprecisely.
I want to count all Sites, which are linked on a homepage and list them.
My earlier solution was, that I have scanned all links and then I have
listed them all in a database.
But, it was a loop and so I fetched all links from the database to scann
them, too!
I didn't thought on this problem:
If I scann all links and insert them into a database, and I fetch them in
the same loop - Then I get always the same links.
Gretting.
"Randell D." <you.can.email.me.at.randelld@yahoo.com> schrieb im Newsbeitrag
news:NQ_ib.98843$6C4.43373@pd7tw1no...[color=blue]
>
> "Sven Dzepina" <mail@styleswitch.de> wrote in message
> news:3f8c1b25$0$11958$9b4e6d93@newsread4.arcor-online.net...[color=green]
> > Hello,
> >
> > How I can realize that?
> > I have this code:
> >
> > <?php
> > $url = "http://www.URL.com;
> > $content = file($url);
> > foreach($content as $line){
> > $pattern =
> >[/color]
>[/color]
"/([\w]+:\/\/[\w-?&;#~=\.\/\@]+[\w\/](\.(html|php|shtml|htm|xhtml|xml)))/i";[color=blue][color=green]
> >
> > $count = 0;
> > if(preg_match_all($pattern,$line,$urls_back_array) ){
> > foreach($urls_back_array[0] as $url_back){
> > $count++;
> > echo $url_back;
> > }
> > }
> > }
> > ?>
> >
> > Now I want to make a loop - My script should count all links of all my[/color]
> *html[color=green]
> > sites. But the script are not allowed to count double! Also the script[/color]
> shall[color=green]
> > count all links on html sites correctly!
> > Example:
> > Home
> > |-Web
> > |-Forum
> > |--Site 1
> > |--Site 2
> > |--Site 3
> > |-Download
> > It should count 7 and list me all! =)
> >
> > Gretting from Germany.
> >
> >[/color]
>
> I'm playing around here trying to do what you want to do... I'm not good
> with my regular expressions using preg tools but I am using a mixture of
> implode and explode to get at the url of each link (ie the "href=" bit in
> the <A HREF" tag)... Once I have the website address that the link is
> targeted at, I plan on using a mix of parse_url() and pathinfo() to[/color]
identify[color=blue]
> html type files. And in order to avoid duplices, the address will be
> written in to an array which I will then run against array_unique.
>
> Do these ideas help any?
>
>[/color] |