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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T22:05:06+00:00 2026-05-31T22:05:06+00:00

I have the following thats within a loop… echo <span class=’srch-val’>.apply_filters( $value\n, $value).</span>; I

  • 0

I have the following thats within a loop…

 echo "<span class='srch-val'>".apply_filters(" $value\n", $value)."</span>";

I want to somehow add a number or something after the class ‘srch-val-1’ without using jQuery, is this possible using PHP? If so where can I find out how to do this? thanks

Its currently within a foreach() loop…

 foreach ( (array) $keys as $key ) { //Stuff }
  • 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-31T22:05:08+00:00Added an answer on May 31, 2026 at 10:05 pm
    echo '<span class="srch-val-'.$your_value.'">'.apply_filters(" $value\n", $value)."</span>";
    

    $your_value can be everything you want , including a number..

    A very simple loop example

    for ($i = 1; $i <= 10; $i++) {
     echo '<span class="srch-val-'.$i.'">'.apply_filters(" $value\n", $value)."</span>";
    }
    

    will return

    <span class="srch-val-1">
    <span class="srch-val-2">
    <span class="srch-val-3">
    .... 10
    

    or for example – in a wordpres loop , you can even do

    echo '<span class="srch-val-'.$post->ID.'">'.apply_filters(" $value\n", $value)."</span>";
    

    or

    echo '<span class="srch-val-'.the_title().'">'.apply_filters(" $value\n", $value)."</span>";
    

    and so on … any available value can be applied . of course you then have to think how to TARGET an over changing class with CSS – but that is for another question,.

    EDIT I – as for comment for the loop inside loop – the above was just a generic example – you need to put the counter in the beginning of your original loop and increment it on the end . (if it is a wordpress loop like i suspect, put $i=1 , or any other number , after the if (have_posts()) or after the while (have_posts()) -depending on where you need it – and the incrementing $i=$i++ at the end. (before the endif; or endwhile; – again depending on your needs…)

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

Sidebar

Related Questions

I have the following for loop executing within my program and I can't see
I have the following code that populates an array (this is within a loop):
I have the following problem: Within a stylesheet document I want to create an
I have the following user control that is embedded within another user control. <UserControl.Resources>
In the following code, I have verified that connecting to a URL from within
I have following code that does not work due to a being a value
I have following code snippet that i use to compile class at the run
HI have a custom view class that is loaded and placed within my main
I have the following array with a structure within each array (see this jsfiddle
I have the following: http://jsfiddle.net/Ve5ZQ/6/ I am attempting to reference the x value in

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.