Need to create a php page This page should display a sentenc

Need to create a php page.

This page should display a sentence of your choosing a random number of times (lets limit to 500 repeats max). The number of times the sentence appears should be different every time they visit this page.

Solution

example.php

<?php

include \'random.php\';

Randy::load(\'sences.txt\');

$posts = Randy::times(100, function() {

    return array(

      \'text\' => Randy::text( Randy::number(500) ), // (a variable number of sentences)

    );

});?>

<h1>random text</h1>

<?php foreach ($posts as $post) { ?>

   <div class=\"post\">

      <p><?=$post[\'text\']?></p>

   </div>

<?php } ?>

random.php

<?php

class Randy {

private static $sentences;

// Start Randy with a random text sample

public static function load($file) {

    $sentences = explode(\".\", file_get_contents($file));

    foreach ($sentences as $k => $sentence) {

      $sentences[$k] = trim($sentence);

      if (empty($sentence)) {

        unset($sentences[$k]);

      }

    }

   

    self::$sentences = $sentences;

  }

// $n times call function $f, and return the results in an array.

// Function $f will have two arguments: the iteration and value $args

public static function times($n, $f, $args = null) {

    $out = array();

    for ($i=0; $i<$n;$i++) {

     $out[] = $f($i, $args);

    }

    return $out;

}

// Return a random member of an array

public function one_of($array) {

    shuffle($array);

    return $array[0];

}

// Returns a random number of results from an array, in an arry

public static function some_of($array) {

    return self::times(Randy::number(count($array)), function($n, $array) { return Randy::one_of($array); }, $array);

}

// Return a random sentence from the sample

public static function sentence() {

    return self::one_of(self::$sentences);

}

// Return a titlelized sentence

public static function title() {

    return ucwords(self::sentence());

}

// Return a random sentence from the sample

static function text($n) {

    $sentences = self::times($n, function() {

      return Randy::sentence();

    });

    return implode(\". \", $sentences).\".\";

}

// Return a random word from the sample

public static function word() {

    $word = trim(self::one_of(explode(\" \", self::sentence())), \'\');

  return ucwords(str_replace(array(\'.\', \',\', \';\'), \'\', $word));

}

// Return a random number between $max en $min

public static function number($max = 20000, $min = 0) {

    return rand($min, $max);

}

// Return a random date between $years ago en $years from now

public static function date($years = 10) {

    return date(\"Y-m-d H:i:s\", time() + self::number(60*60*24*365*$years, -60*60*24*365*$years));

}

// Return a robohash image url with $size.

public static function image($size = 100, $seed = false) {

    if (!$seed) {

      $seed = Randy::number(25000); }

   

    return \"http://robohash.org/\".$seed.\".png?size=\".$size.\"x\".$size;

}

// Return a random IP adress

public static function ip() {

    return Randy::number(255).\".\".Randy::number(255).\".\".Randy::number(255).\".\".Randy::number(255);

}

// Return a random email address

public static function email() {

    return strtolower(Randy::word()).\"@example.com\";

}

// Return true or false

public static function bool() {

    return self::one_of(array(true, false));

}

// Return a kind of name

public static function name() {

    return self::salutation().\" \".self::word().\" \".substr(self::word(),0,1).\". \".self::word();

}

public static function salutation() {

    return self::one_of(array(\'Mr.\', \'Ms.\', \'Miss.\', \'Dr.\'));

}

// Return a random URL

public static function url() {

    return strtolower(\"http://\".Randy::word().\".example.com/\".Randy::word().\"/?\".Randy::word().\"=\".Randy::word() );

}

}

sentence.txt

Lorem ipsum shiznit get down get down amizzle, consectetuer adipiscing hi. Sizzle we gonna chung velizzle, gizzle volutpizzle, suscipizzle quis, fizzle vizzle, arcu. Pellentesque doggy i\'m in the shizzle. Sed erizzle. Cool shizzlin dizzle dolor dapibus sure shiznit . Mauris you son of a bizzle nibh izzle phat. Its fo rizzle izzle hi. Pellentesque gangster bizzle for sure. In gizzle habitasse get down get down dictumst. Sheezy dapibizzle. Curabitizzle tellus cool, pretizzle eu, mattizzle izzle, yo fo, shiz. Stuff suscipizzle. Integizzle fo shizzle velit doggy purus.

Praesent non pizzle crackalackin mauris shizzle my nizzle crocodizzle bibendizzle. Fo gangster viverra lectizzle. Yo mamma bling bling break yo neck, yall own yo\' gangsta sodalizzle hi. Aliquizzle lobortizzle, fo shizzle mah nizzle fo rizzle, mah home g-dizzle bling bling dapibizzle fo, nulla owned bibendizzle my shizz, izzle shizznit hi dui izzle check it out. Ghetto gravida lacizzle bow wow wow things. Vivamus arcu doggy, fo shizzle mah nizzle fo rizzle, mah home g-dizzle sit amizzle, ma nizzle izzle, cool ac, maurizzle. Sizzle vehicula laorizzle black. Vestibulizzle erat cool, hendrerit et, condimentum shut the shizzle up, ghetto things, shiznit. Away dang placerizzle pizzle. Shizzle my nizzle crocodizzle boofron erizzle doggy erizzle. Pimpin\' metus sem, egestizzle boofron, pizzle hi, elementizzle egizzle, neque. Break yo neck, yall iaculizzle go to hizzle a orci tincidunt pimpin\'. Fusce sagittis, fo shizzle break yo neck, yall i saw beyonces tizzles and my pizzle went crizzle my shizz, lacizzle quam luctus mofo, vitae own yo\' augue purizzle vitae arcu. Etizzle shut the shizzle up. Nunc sizzle mi. Duis uhuh ... yih! turpis. Vestibulizzle a magna. Fizzle fo shizzle erizzle, consectetuer id, da bomb ac, rizzle izzle, pede. Owned tellus. Nulla dawg erizzle, nizzle sizzle amet, bow wow wow get down get down, i saw beyonces tizzles and my pizzle went crizzle its fo rizzle, augue.

Hizzle tellizzle ghetto, pulvinizzle izzle, condimentum egizzle, vehicula we gonna chung, dizzle. Etiam sizzle leo phat sem hendrerit bling bling. Bling bling interdizzle magna away eros commodo ullamcorper. We gonna chung lobortis you son of a bizzle ligula. Break yo neck, yall odio. Maecenas gizzle fo ac pizzle hizzle sizzle. Integizzle fo shizzle my nizzle viverra urna. Ghetto sollicitudizzle boom shackalack dope mammasay mammasa mamma oo sa. Morbi sure ligula sizzle for sure tellizzle. Nam lobortis enizzle vitae arcu. Cizzle socizzle natoque shizzle my nizzle crocodizzle izzle magnizzle dis crunk own yo\', nascetur dizzle break it down.

Integizzle izzle metus shizzlin dizzle arcu go to hizzle gangsta. Yo mamma boofron. Shut the shizzle up da bomb da bomb. Pizzle crackalackin brizzle, hendrerit izzle, funky fresh izzle, euismod quizzle, massa. Vestibulizzle funky fresh. Ut vehicula mofo gangsta. Bow wow wow check out this, orci a suscipit crunk, enim check it out yo we gonna chung, dang my shizz dizzle nulla nizzle fo shizzle my nizzle. We gonna chung own yo\' sollicitudizzle uhuh ... yih!. Quisque shizzlin dizzle maurizzle, nonummy izzle, malesuada izzle, bibendum varizzle, yippiyo. izzle, ligula vel pretizzle sizzle, velit posuere break yo neck, yall, a tempor justo ma nizzle sit amet augue. Owned izzle lacus bizzle shizznit yippiyo shiz. Quisque izzle sheezy justo. Nam vehicula boofron shizznit. Suspendisse break yo neck, yall. We gonna chung placerat leo its fo rizzle mi. Etizzle pellentesque. In hac we gonna chung platea dictumst. Crizzle break yo neck, yall leo sizzle dizzle tempizzle eleifend. Ass erizzle ante, pulvinizzle break yo neck, yall, that\'s the shizzle a, consectetizzle , nisl. Owned vizzle fo shizzle my nizzle ut neque tempizzle fo shizzle.

Nunc bizzle erizzle ma nizzle urna. Izzle congue. Vestibulizzle viverra laoreet dui. Quisque fo shizzle mah nizzle fo rizzle, mah home g-dizzle ma nizzle purizzle leo volutpat that\'s the shizzle. Its fo rizzle potenti. Nunc izzle sem shiz purus tincidunt bling bling. Sizzle gravida tempizzle yo mamma. In check out this erizzle et fizzle. Crazy malesuada. Hi fizzle the bizzle sizzle diam mollizzle for sure. Nulla away. Owned quizzle quizzle hizzle massa its fo rizzle pulvinar. Da bomb sagittis get down get down hendrerit crunk. Nizzle away metus dizzle tellizzle. Etiam pretium purus nizzle dui. Ma nizzle rutrizzle rhoncizzle mofo.

Praesent bling bling nisi quis justo molestie phat. Things mi, dapibus fo, lobortis sizzle, pizzle at, nisl. Its fo rizzle check it out. Suspendisse consectetizzle. Check out this away we gonna chung, luctizzle dope, bibendizzle nizzle, bibendizzle izzle, dolor. That\'s the shizzle sed shizzlin dizzle. Maecenizzle vizzle tortor. Cras izzle nibh. Vestibulizzle shizzle my nizzle crocodizzle. Donizzle dignissizzle sapizzle vel da bomb. Ghetto a gangster mah nizzle sizzle eleifend boom shackalack. Fusce daahng dawg, nibh fo shizzle for sure fringilla, neque you son of a bizzle tempor erat, fo shizzle my nizzle break yo neck, yall augue nunc lacinia pede. Quisque vestibulizzle ma nizzle dang. Aliquam erat volutpat. In sagittizzle, funky fresh izzle gangsta ass, massa break it down fo shizzle my shizz, at sagittizzle uhuh ... yih! metizzle sed nibh.

output:

randomtext

Quisque shizzlin dizzle maurizzle, nonummy izzle, malesuada izzle, bibendum varizzle, yippiyo. Bling bling interdizzle magna away eros commodo ullamcorper. We gonna chung lobortis you son of a bizzle ligula. Crazy malesuada. Vestibulizzle viverra laoreet dui. Away dang placerizzle pizzle. Vestibulizzle a magna. Nulla away. Its fo rizzle potenti. Its fo rizzle izzle hi. yih! turpis. Fusce sagittis, fo shizzle break yo neck, yall i saw beyonces tizzles and my pizzle went crizzle my shizz, lacizzle quam luctus mofo, vitae own yo\' augue purizzle vitae arcu. Quisque vestibulizzle ma nizzle dang. Sheezy dapibizzle. Bow wow wow check out this, orci a suscipit crunk, enim check it out yo we gonna chung, dang my shizz dizzle nulla nizzle fo shizzle my nizzle. Fusce daahng dawg, nibh fo shizzle for sure fringilla, neque you son of a bizzle tempor erat, fo shizzle my nizzle break yo neck, yall augue nunc lacinia pede. Pellentesque doggy i\'m in the shizzle. Pellentesque gangster bizzle for sure. Nunc bizzle erizzle ma nizzle urna. izzle, ligula vel pretizzle sizzle, velit posuere break yo neck, yall, a tempor justo ma nizzle sit amet augue. Break yo neck, yall iaculizzle go to hizzle a orci tincidunt pimpin\'. Yo mamma bling bling break yo neck, yall own yo\' gangsta sodalizzle hi. Check out this away we gonna chung, luctizzle dope,

excution steps:

for working above code we need to excute example.php and above code is put in one folder and than excute it

Need to create a php page. This page should display a sentence of your choosing a random number of times (lets limit to 500 repeats max). The number of times th
Need to create a php page. This page should display a sentence of your choosing a random number of times (lets limit to 500 repeats max). The number of times th
Need to create a php page. This page should display a sentence of your choosing a random number of times (lets limit to 500 repeats max). The number of times th
Need to create a php page. This page should display a sentence of your choosing a random number of times (lets limit to 500 repeats max). The number of times th
Need to create a php page. This page should display a sentence of your choosing a random number of times (lets limit to 500 repeats max). The number of times th

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site