Replacing string array elements
Posted: Thu Dec 13, 2012 1:54 am
Sorry for the title of this, as it's probably not the right lingo
My PHP skills are limited to being able to do what I want with my wordpress blog, but that's about all.
I want to place a string, bible verses specifically, and have something that pulls all the verse numbers from the string, wrap them in HTML tags that I style with css, and then put everything back where it goes, with the numbers wrapped in the tags. I found this online and it pulls the numbers out, and I've gotten them wrapped in the HTML tags, but how do I output everything back where it was, leaving the tags that I added?
I know people get irritated when other people ask them to write their code, but I'm just curious if someone knows of a simple function that I'm aware of. I've spent several hours searching online, but some of it is just over my head at the moment.
I can figure out how to output just the numbers with the tags using a foreach loop, but I have no idea how to output it back where it went.
I want to place a string, bible verses specifically, and have something that pulls all the verse numbers from the string, wrap them in HTML tags that I style with css, and then put everything back where it goes, with the numbers wrapped in the tags. I found this online and it pulls the numbers out, and I've gotten them wrapped in the HTML tags, but how do I output everything back where it was, leaving the tags that I added?
I know people get irritated when other people ask them to write their code, but I'm just curious if someone knows of a simple function that I'm aware of. I've spent several hours searching online, but some of it is just over my head at the moment.
Code: Select all
//Creates the function to extract numbers
function extract_numbers($string) {
preg_match_all('/([\d]+)/', $string, $match);
return $match[0]; }