dimanche 18 septembre 2022

PHP script that show content from random pages

  1. I need to show content from 3 pages at once in my index.php ;
  2. Extract the content from every page (only 3 pages), from line 50 (start) to 100 line (stop).
  3. Random order for the 3 content extracted.

Code for random content (shows only 1 result, not 3)

<?php
srand();
$files = array("folder/content1.php", "folder/content2.php", "folder/content3.php", "folder/content4.php", "folder/content5.php", "folder/content6.php");
$rand = array_rand($files);
include ($files[$rand]);
?>

This is the code to extract content from pages:

<?php $section1 = file_get_contents("folder/content1.php", FALSE, NULL, 50, 100); echo $section1; ?>
<?php $section2 = file_get_contents("folder/content2.php", FALSE, NULL, 50, 100); echo $section2; ?>
<?php $section3 = file_get_contents("folder/content3.php", FALSE, NULL, 50, 100); echo $section3; ?>
<?php $section4 = file_get_contents("folder/content4.php", FALSE, NULL, 50, 100); echo $section4; ?>
<?php $section5 = file_get_contents("folder/content5.php", FALSE, NULL, 50, 100); echo $section5; ?>
<?php $section6 = file_get_contents("folder/content6.php", FALSE, NULL, 50, 100); echo $section6; ?>



Aucun commentaire:

Enregistrer un commentaire