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 8149203
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T14:48:08+00:00 2026-06-06T14:48:08+00:00

Trying to get a list of all substrings currently I have a function but

  • 0

Trying to get a list of all substrings currently I have a function but it’s not fully complete. Im using minimum char of 4. What would be a good approach to complement this:

Im also need to find words like “predict”, how can this be done best and fastest?

Output

Word:      predictions
Substring: predictions
Substring: redictions
Substring: edictions
Substring: dictions
Substring: ictions
Substring: ctions
Substring: tions
Substring: ions
  • 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-06-06T14:48:09+00:00Added an answer on June 6, 2026 at 2:48 pm

    The following will create a substring trimming from the right and left of the word down to length of 4 in the same loop. That was the specification I understood.

    $length = strlen($word) - 4;
    for ($i = 1; $i <= $length; ++$i) {
        echo "left = ", substr($word, $i), PHP_EOL;
        echo "right = ", substr($word, 0, -$i), PHP_EOL;
    }
    

    Assumption: By words you mean substrings.

    Note: I also added the logic for a minimum length of 4 characters as well as micro-optimized the for loop (static limit and pre-increment counter).

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

Sidebar

Related Questions

I was trying to write a function to get all subsequences of a list
I am trying to get all list items of a sharepoint list using WebServices
I'm trying to get a list of all the sockets/clients that are currently connected.
I'm trying to get a list of all the users from users table and
I am trying to get the code to list all the directories in a
Here's what I'm trying to do: I want to get a list of all
I'm trying to LEFT JOIN two tables, to get a list of all rows
I'm trying to get a list of user's friends using fb connect for the
I'm trying to get a list of stored procedures in t-sql. I am using
I am trying to get a list of all Google Apps users of a

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.