Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6560251
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:26:09+00:00 2026-05-25T13:26:09+00:00

Like: The quick, brown fox jumps over a lazy dog. DJs flock by when

  • 0

Like:

The quick, brown fox jumps over a lazy dog. DJs flock by when MTV ax quiz prog. Junk MTV quiz graced by fox whelps. Bawds jog, flick quartz, vex nymphs. Waltz, bad nymph, for quick jigs vex! Fox nymphs grab quick-jived waltz. Brick quiz whangs jumpy veldt fox. Bright vixens jump; dozy fowl quack. Quick wafting zephyrs vex bold Jim. Quick zephyrs blow, vexing daft Jim.

(this is just sample text, the real one is much longer)

How can I get let’s say 5 words from this text?

I tried using explode(' ', $text); Then shuffle the array and pick 5 elements from it, but I get all the punctuation and other characters. I just want a-z characters. Also the words need to have at least 3 characters

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T13:26:10+00:00Added an answer on May 25, 2026 at 1:26 pm

    You can use the built-in str_word_count for this:

    $words = str_word_count($str, 1);
    shuffle($words);
    $selection = array_slice($words, 0, 5);
    

    See it in action.

    You can also use another way (such as array_rand) of picking out random words from the $words array if you are concerned about performance; this is just the most convenient.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

<?php $string = 'The quick brown fox jumped over the lazy dog.'; $patterns[0] =
Suppose I'm parsing the following line: The quick brown fox jumps over the lazy
I initialize a string as follows: std::string myString = 'The quick brown fox jumps
I have the following HTML: <html> <body> <h1>Foo</h1> <p>The quick brown fox.</p> <h1>Bar</h1> <p>Jumps
Lets say I have the following sentence: A quick brown fox jumped over a
Say I have a sentence similar to the following: The quick brown fox jumps
I have this string: The quick brown f0x jumps 0ver the lazy d0g, the
Say I have a string like this: $string = 'The /*quick*/ brown /*fox*/ jumped
Let's say I have a list of words, something like this: ['The', 'Quick', 'Brown',
Stuart Halloway gives the example (re-seq #\w+ The quick brown fox) as the natural

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.