Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get random text from lorem Ipsum in PHP?

Tags:

I want the random text from Lorem Ipsum so I can use it when generating webpages. I can't find any PHP functions that does this and I'm wondering if there's any publicly available libraries or APIs on sites that could be used to get some random text?

like image 452
Celeritas Avatar asked Dec 17 '13 11:12

Celeritas


1 Answers

$content = file_get_contents('http://loripsum.net/api');

Docs in the bottom right of this page:

Just do a GET request on loripsum.net/api, to get some placeholder text. You can add extra parameters to specify the output you're going to get. Say, you need 10 short paragraphs with headings, use http://loripsum.net/api/10/short/headers. All of the possible parameters are:

  • (integer) - The number of paragraphs to generate.
  • short, medium, long, verylong - The average length of a paragraph.
  • decorate - Add bold, italic and marked text.
  • link - Add links.
  • ul - Add unordered lists.
  • ol - Add numbered lists.
  • dl - Add description lists.
  • bq - Add blockquotes.
  • code - Add code samples.
  • headers - Add headers.
  • allcaps - Use ALL CAPS.
  • prude - Prude version.
  • plaintext - Return plain text, no HTML.
like image 181
Niels Keurentjes Avatar answered Dec 31 '22 12:12

Niels Keurentjes