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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T04:10:05+00:00 2026-06-19T04:10:05+00:00

I have a simple foreach like the following: $range = range(1, 10); foreach ($range

  • 0

I have a simple foreach like the following:

$range = range(1, 10);
foreach ($range as $times) {
   echo 'example' . $times . '<br>';
}

what would output the result below-

example1
example2
example3
example4
example5
example6
example7
example8
example9
example10

instead of having the echo 'example' . $times . '<br>';
i would like to echo one variable and have the same result, any answers welcome.

  • 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-19T04:10:06+00:00Added an answer on June 19, 2026 at 4:10 am

    You mean build a string?

    $results = '';
    foreach(range(1, 10) as $i) {
       $results .= "example${i}\n";
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Would like to get the following as a result from the table structure below
I have a very simple query $this->db->select('id, title'); $this->db->order_by('id', 'DESC'); $query = $this->db->get('journal'); foreach($query->result()
I have the following problem - I would like to compute a field in
I have something simple like the following, where I call the script for 5
I have an extremely simple JSON object that looks like the following: var data
I have a SimpleXML element, from XML like the following: <Result> <BlueAnswer>Blue</BlueAnswer> <RedAnswer>Red</RedAnswer> <YellowAnswer>Yellow</YellowAnswer>
I have a simple Parallel.Foreach loop that has about 1000 rows in the DataTable,
I have a pretty simple case which I started solving using foreach(), but then
I have what seems like a simple problem with some data in Excel. I
Can I do something like the following in Perl? foreach (@tokens) { if (/foo/){

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.