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

  • Home
  • SEARCH
  • 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 8175741
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T22:53:03+00:00 2026-06-06T22:53:03+00:00

here is myproblem, i want to make a php function to insert some random

  • 0

here is myproblem, i want to make a php function to insert some random letter to specific word.

example :

random letter : a,i,u,e,o

specific word : monkey,deer,tiger,mouse

sentence : a tiger eating a deer, monkeys and rats see from a distance

I want the sentence to be like this:

a tiager eating a dueer, monkeiys and raats see from a distance

  • 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-06T22:53:04+00:00Added an answer on June 6, 2026 at 10:53 pm
    $sentence = 'a tiger eating a deer, monkeys and rats see from a distance'; // You'll need to load the string into a variable, obviously.
    
    $randomLetterArray = array('a', 'e', 'i', 'o', 'u'); // It's good to set the random letters inside an array so that they can be randomly picked by randomizing the index number.
    
    $specificWordArray = array('monkey', 'deer', 'tiger', 'mouse'); // Words to be altered in an array to easily iterate through.
    
    foreach ($specificWordArray as $specificWord) // Iterating through each of the words to be altered.
    {
        $indexOfWord = rand(0, strlen($specificWord)-1); // Getting a random number between 0 and the length (in chars) of the word.
        $partOfWord = substr($specificWord, 0 , $indexOfWord); // Getting a part of the word based on the random number created above.
        // This is more complex.
        // The part of the word created above is concatenated by a random selection of one of the random letters.
        // This in turn is concatenated by the remaining letters in the word.
        $wordReplacement = $partOfWord.$randomLetterArray[rand(0, count($randomLetterArray)-1)].substr($specificWord, $indexOfWord);
        $sentence = str_ireplace($specificWord, $wordReplacement, $sentence); // This replaces the word in the sentence with the new word.
    }
    echo $sentence;
    

    I hope this gives you some ideas into how to approach the problem, and I hope the comments help to give an idea of the functions available to you in PHP.

    Good luck!

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

Sidebar

Related Questions

I want to make some API calls to a server using HttpURLConnection . But
My problem has to do with PHP, jQuery and CSS. I want to make
I want to make a deep copy method. I seeked help here the other
I'm new to Ruby, Regex and Stackoverflow. xD Here's my problem: I want to
Here is my problem. I want to create n number of QLineEdit widgets (
Here is my problem: http://testepi.kvalitne.cz/test/ I do not want the delay between a keypress
here is my Problem, I want to pass the integer 1 when this canvas
Here is my problem, I want to track if user is online or offline
So here is my problem. I want to redirect name.domain.com/trips/1 to domain.com?username=name&trip=1 using modrewrite.
So here is my problem. I want to store 2-tuple (key, val) and want

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.