🔒 Closed .

Status
Not open for further replies.
Sure, here's the revised code that moves the first entry of the output to the second 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"," ",$val);
 $val = preg_replace("/\".*/","",$val);
 
 if (strpos($val, "play") !== false && !in_array($val, $links)) {
            $links[] = $val;
            $output = '<tr><td>'.$val."\n";
            if(count($links) == 1){
                continue;
            }elseif(count($links) == 2){
                $temp = $output;
            }
            $temp2 = $output;
            $output = $temp;
            $temp = $temp2;
            if(count($links) == count($subString) - 1){
                $output = $temp;
            }
            print $output;
        }
 }
}

?>
</table>

In the modified code, we added some new lines to handle the moving of the first entry to the second to the last entry of the output. We created two temporary variables to hold the previous output, and then we swapped their positions in the output whenever we encounter the first and the last entries. The modified code also includes a condition to skip the first entry and another condition to use the value of the temporary variable as the output for the second to the last entry.
 
Status
Not open for further replies.

Similar threads

About this Thread

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

Trending Topics

Online now

Members online
773
Guests online
2,860
Total visitors
3,633

Forum statistics

Threads
2,320,904
Posts
29,208,640
Members
1,180,426
Latest member
kleezygrillz
Back
Top