I have a string inside another to which I need to append something.
The structure of string is something like this:
$output = "Family: peppers, dimensions: 150 cm, origin: South America, Pot diameter: 14, height with pot: 80";
In that string I need to find Pot diameter and append to its numeric value the string cm. so it will look like
Pot diameter: 14 cm.
In the site it appears like this:
Family: peppers.
Dimensions: 150cm
Origin: South America
Pot diameter: 14
Height with pot: 80
I have been trying to use preg_replace() via
$output = preg_replace("/Pot diameter: [0-9]+/", ' cm.', $output)
but it doesn’t work at all. I can’t figure out how to find a number within given string – an exact number won’t work because it’s used dynamically. Only letters inside this string are static.
I figure out that Source code shows:
<div><br/>
<b>Średnica doniczki: </b>
14<br/>
</div>
Changing to:
$output = preg_replace("/<b>Średnica doniczki: </b> <br/>[0-9]+/", ' cm.', $output);
Dosen’t work either.