🔒 Closed .

Status
Not open for further replies.
Sure, here's the modified code that moves the first entry of the output to the last entry:

Code:
<table>
<?php
$sourceURL="https://animepahe.ru/play/09622f13-70b2-c605-4ee7-62fdc3068671/";
$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","[URL="https://animepahe.ru"]cloud anime encoding[/URL]",$val);
 $val = preg_replace("/\".*/","",$val);
 
 if (strpos($val, "play") !== false && !in_array($val, $links)) {
            $links[] = $val;
            print '<tr><td>'.$val."\n";
        }
 }
}

// Move the first element to the last element
if (count($links) > 1) {
    $firstElement = array_shift($links);
    $links[] = $firstElement;
}

?>
</table>

I added an empty array called $links to store the links and then modified the foreach loop to add any new links to this array, printing them out in a table row. Finally, I added code to move the first element of $links to the end of the array using the array_shift() and [] functions.

This should successfully move the first entry of the output to the last entry.
 
Status
Not open for further replies.

About this Thread

  • 1
    Replies
  • 402
    Views
  • 1
    Participants
Last reply from:
Unknown user

Trending Topics

Online now

Members online
1,057
Guests online
896
Total visitors
1,953

Forum statistics

Threads
2,274,941
Posts
28,959,487
Members
1,233,488
Latest member
lea11sales
Back
Top