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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:47:14+00:00 2026-05-29T05:47:14+00:00

I am trying to generate a random bit of html via php, I can’t

  • 0

I am trying to generate a random bit of html via php, I can’t get it to work?

$i = 96;
$minder = '';
while($i >= 0) {
    // 1
    if (rand(0, 1) == 0) {
        $minder . '<li class="0 1" title="1"></li>';
    // 2
    } else {
        $minder . '<li class="0 2" title="2"></li>';
    }
    --$i;
}
echo $minder;

How do I get the li to append to the string minder? I should end up with a list of 96 li?

  • 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-29T05:47:15+00:00Added an answer on May 29, 2026 at 5:47 am

    Syntax should be:

    $minder .= '<li class="0 2" title="2"></li>';
    

    Note the .=

    Concatenating two strings is done with a . (i.e. $string = "first part"." second part";) but if you want to concatenate a string to an existing variable, you can do it the long way:

    $existing_string = $existing_string." some more text";
    

    or use the shorthand syntax, which is much simple:

    $existing_string .=" some more text";
    

    Also… your class names!
    Using a numeric digit as a class name is going to give you headaches down the road. Technically you can do it, but it requires vigilance and you may just want to avoid it by calling your class ‘class_1’ and ‘class_2’, etc. From w3c:

    In CSS1, a class name could start with a digit (“.55ft”), unless it
    was a dimension (“.55in”). In CSS2, such classes are parsed as unknown
    dimensions (to allow for future additions of new units). To make
    “.55ft” a valid class, CSS2 requires the first digit to be escaped
    (“.\35 5ft”)

    Given how easy it is to just avoid this, I’d follow Triptych’s rule on this:

    A name [should] begin with an underscore (_), a dash (-), or a
    letter(a–z), followed by any number of dashes, underscores, letters,
    or numbers. There is a catch: if the first character is a dash, the
    second character must2 be a letter or underscore, and the name must be
    at least 2 characters long.

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

Sidebar

Related Questions

What I am trying to do is get the UserID to generate random values
I'm trying to generate some 8-bit random numbers with C++ and don't want to
I am trying to generate a random password in php. However I am getting
I am trying to generate random floats using nothing but bytes I get from
I'm trying to generate random permutations of an 80-character fixed string in C. Much
What is the best way to generate a random DateTime in Ruby/Rails? Trying to
I'm trying to wrtie a facebook application that generates random quotes using php. However,
While trying to generate classes from a xsd, i got this error: java.lang.IllegalArgumentException: Illegal
I'm trying to generate a unique ID in php in order to store user-uploaded
I'm trying to generate random numbers from a gaussian distribution. Python has the very

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.