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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:51:58+00:00 2026-05-27T19:51:58+00:00

I have a variable called $core I also have 3 other variables called $one,

  • 0

I have a variable called

  $core

I also have 3 other variables called

 $one, $two, $three

I need to (many times) display a random combination of these where $core is always included and 1 of the 3 other variables are included once either before or after:

eg:

 $two $core
 $core $one
 $three $core
 $core $two

I’m unsure how to get this randomness working with PHP?
A push in the right direction would be greatly appreciated.

thx

  • 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-27T19:51:58+00:00Added an answer on May 27, 2026 at 7:51 pm

    Hold the three variables in an array. Then call rand() between 0 and 1 to determine whether an array value or $core should be printed first. At the same time, call a random value from the array

    // Array of the three vars
    $arr = ($one, $two, $three);
    // If 0 is chosen, print an array value then $core. 
    // Otherwise print $core than an array value
    echo rand(0, 1) == 0 ? $arr[rand(0,2)] . " " . $core : $core . " " . $arr[rand(0,2)];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to split one variable into 3 variables. For example I have a
I have a PHP-variable called $go_Adress which contains the adress I need to get
1) Refcounted pointers need stack variables to have constructors / destructors called at predictable
I have a variable called account_type passed from a rails form and need to
I have a variable called names which is a two dimensional array. I declared
Say you have a variable called hotelPropertyNumber . The contents will always be a
I have a hidden input variable called str. I am assigning abc value to
Say I have stored a query in a variable called $query. I want to
I have a huge dictionary of blank values in a variable called current like
I have a paragraph of text in a javascript variable called 'input_content' and that

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.