Celeritas Celeritas - 1 year ago 112
PHP Question

How to get random text from lorem Ipsum in PHP?

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?

Answer Source

$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.
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download