🔒 Closed .

Status
Not open for further replies.
Here's the rewritten code with the duplication check added:

PHP:
<?php
$sourceURL = "https://animepahe.ru/play/0a0ed35a-869a-b3b0-1bce-0357997a2895/e43a8e949e0d2581e3aad9390c60d327a4ea503b6e1ec70e56dbc3e066fdf177";
$content = file_get_contents($sourceURL);
$content = strip_tags($content, "<a>");
$subString = preg_split("/<\/a>/", $content);

$links = [];

foreach ($subString as $val) {
    if (strpos($val, "<a href=") !== false) {
        $val = preg_replace("/.*<a\s+href=\"/sm", "", $val);
        $val = preg_replace("/\".*/", "", $val);
        if (strpos($val, "play") !== false && !in_array($val, $links)) {
            $links[] = $val;
            echo '<tr><td>' . $val . "\n";
        }
    }
}
?>

I added an empty array $links to keep track of the links that have already been processed. Before processing a link, it checks if it's already in the array using in_array() function. If it's not, it adds it to the array and processes it. This avoids duplicate entries.
 
Here's the rewritten code with the duplication check added:

PHP:
<?php
$sourceURL = "https://animepahe.ru/play/0a0ed35a-869a-b3b0-1bce-0357997a2895/e43a8e949e0d2581e3aad9390c60d327a4ea503b6e1ec70e56dbc3e066fdf177";
$content = file_get_contents($sourceURL);
$content = strip_tags($content, "<a>");
$subString = preg_split("/<\/a>/", $content);

$links = [];

foreach ($subString as $val) {
    if (strpos($val, "<a href=") !== false) {
        $val = preg_replace("/.*<a\s+href=\"/sm", "", $val);
        $val = preg_replace("/\".*/", "", $val);
        if (strpos($val, "play") !== false && !in_array($val, $links)) {
            $links[] = $val;
            echo '<tr><td>' . $val . "\n";
        }
    }
}
?>

I added an empty array $links to keep track of the links that have already been processed. Before processing a link, it checks if it's already in the array using in_array() function. If it's not, it adds it to the array and processes it. This avoids duplicate entries.
ang galing ng phc bot na solve nya yung coding. very nice.

very easy. naayos din yung output.
 
Status
Not open for further replies.

Similar threads

About this Thread

  • 6
    Replies
  • 485
    Views
  • 4
    Participants
Last reply from:
STRATEGY

Trending Topics

Online now

Members online
1,238
Guests online
5,656
Total visitors
6,894

Forum statistics

Threads
2,305,608
Posts
29,166,793
Members
1,195,370
Latest member
BraderKho
Back
Top