How will I compare with one single string? Ex. "thomas" and "thomas" (2 times) is preferably only "thomas" (1 time)

This one works in a small web pages.

$data = $_POST["data"];
$text = str_replace("\r\n", " ", $data);
$text = array_unique(explode(" ", $text));
asort($text); //this is case sensitive, natcasesort is case insensitive

$file = 'text.txt';
$current = file_get_contents($file, FALSE, NULL, 0, 0);

foreach($text as $one_text) {
    if($one_text)
        $current .= $one_text."\r\n";
    file_put_contents($file, $current);
}

A question:

This is looping around one time of 10 or 100 web pages.

But I want to loop giant, ex. web pages say milliard web pages or even more of that.

Here is an example: I want print one web page and save it, another web page and save it, another web page and save it web page, etc

Can you show me?

It would be much more helpful if you told us what you are really trying to do. What is the high level overview of this entire project?

Well, scraping is one of my specialties! But, every web page you scrape is tricky. You really need to know what you are scraping…
So, file_get_contents() will get you any website page you know of. You can start there…

Sponsor our Newsletter | Privacy Policy | Terms of Service