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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T22:25:17+00:00 2026-06-17T22:25:17+00:00

After some digging, I’m still not getting any close with this. I have a

  • 0

After some digging, I’m still not getting any close with this.

I have a html string produced by this php…

This strips out all multiple white spaces.

For example the above outputs this string below, no other nodes contained, just text…

 1 Lorem ipsum 1.1 Dolor sit amet, consectetur adipiscing elit. 1.2 Nulla non felis enim, a lacinia erat. 1.3 Donec ullamcorper feugiat lobortis. 1.4 Vivamus congue libero ut augue consectetur ultricies vitae eget quam. 2 Suspendisse 2.1 Ultrices volutpat tempus. 2.2 Aenean ullamcorper porta lacus, ut vehicula tortor dapibus hendrerit. 2.3 Proin condimentum est eget arcu mollis consequat. 2.4 Ut malesuada posuere lobortis. 2.5 Suspendisse gravida adipiscing nunc, et vehicula nunc tincidunt nec. 3 Tincidunt 3.1 Sed eget porta ligula. 3.2 Morbi vitae augue in eros tincidunt tincidunt consequat interdum dui. 3.3 Phasellus ante velit, venenatis et dignissim eu, semper vitae lectus. 3.4 Maecenas feugiat adipiscing tortor, non porttitor sem condimentum luctus. 3.5 Curabitur pharetra gravida ornare. 3.6 Donec tortor erat, posuere in ullamcorper eget, posuere sit amet purus. 3.7 Duis feugiat sollicitudin odio, ac molestie nulla elementum non. 4 Vestibulum 4.1 Tempor lectus sit amet purus condimentum nec condimentum dui viverra. 4.2 Duis sodales molestie fermentum. 4.3 Maecenas euismod, lacus ut ullamcorper condimentum, erat felis sodales lectus, a sodales ipsum lectus eu lorem. 4.3 Vivamus ac rhoncus est.

I am trying to find away of find all the numbers (1 , 1.2 , 1.3 , etc) and wrap them in a span.

I tried php but I was not having much luck…

$phrase  = "You should eat fruits, vegetables, and fiber every day.";
$healthy = array("fruits", "vegetables", "fiber");
$yummy   = array("pizza", "beer", "ice cream");

$newphrase = str_replace($healthy, "<span>".$yummy."</span>", $phrase);

echo $newphrase;

the above php is outputting this… You should eat Array, Array, and Array every day.

So I thought I could maybe try jquery, but I’m not sure if I’m approaching it correctly, please my code…

var points = [' 1 ',' 1.1 ',' 1.2 ',' 1.3 ',' 1.4 ',' 2 '];

$("p").html(this.html().replace( points,'<span>' + points + '</span>'));

I think I’m way off track but I can’t really find much on pin pointing specific bits of string.

I made a fiddle of my jQuery… http://jsfiddle.net/XmU6p/

I guess in the mean time, I’m going to still pursue this problem. But if anyone could please share some pointers as to where I’m going wrong, I would be most grateful. Thanks

  • 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-17T22:25:18+00:00Added an answer on June 17, 2026 at 10:25 pm

    In both cases you need to actually loop through the array of values and do the replacement for each value. I’m not too familiar with PHP, so I’ve made an example using jQuery. Try this:

    var points = [' 1 ',' 1.1 ',' 1.2 ',' 1.3 ',' 1.4 ',' 2 '];
    $.each(points, function(i, val) {
        var $p = $('p');
        $p.html($p.html().replace(val, '<span>' + val + '</span>'));
    });
    

    Updated fiddle

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

Sidebar

Related Questions

Update: I updated this after doing some digging and realizing that this might be
After some digging around on SO I found this as the best response for
I'm trying to flip an NSImage created with a NSImageBitmapRep representation. After some digging
After some time researching and trying different things I still cannot get my @ExceptionHandler
After some recursive function I have an array: first iteration: Array ( [category_id] =>
after some advice regarding a problem i am getting using a linux based piece
After some digging around with the Wordpress XML-RPC documentation , it seems that there
I was doing some digging around into delegate variance after reading the following question
Second Update After doing some more digging, there seems to be a bigger issue
I love Go, especially the goroutines. They are simple and efficient. After some digging,

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.