# str\_replace() for a string

**URL:** <https://forum.kirupa.com/t/str-replace-for-a-string/310046>\
**Category:** programming\
**Created:** [May 31, 2010, 11:17am UTC](https://forum.kirupa.com/t/str-replace-for-a-string/310046 "2010-05-31T11:17:24Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Env](https://avatars.discourse-cdn.com/v4/letter/e/d9b06d/32.png) [@Env](https://forum.kirupa.com/u/Env)\
**Post date:** [May 31, 2010, 11:17am UTC](https://forum.kirupa.com/t/str-replace-for-a-string/310046/1 "2010-05-31T11:17:24Z")

</div>

Hi

I have an admin panel where the admin puts certain information about a products details that tell the customer about the size dimensions. I want to get this data and place it on the products page in separate divs.

Additional info: 1.17mm 2.53mm 3.140mm

The admin uploads the data like that above. So “1.” and followed by a number for the measurement ending with mm

The first is height, width and length.

It echos like this

```auto

<?
$choc = $item->long_description_2;
echo $choc;
?>

```

Result “1.17mm 2.53mm 3.140mm”

I want it like:

\<div class=“heightframe”\>1.17mm\</div\>\<div class=“widthframe”\>2.53mm\</div\>\<div class=“lengthframe”\>3.140mm\</div\>

I am trying to use STR\_Replace. I would normally use Classic ASP but my client has a PHP server so it is pretty new to me… not really new but pretty…

\<?  
$choc = $item-\>long\_description\_2;  
echo str\_replace(“1.”,"\<div class=‘heightframe’\>",“2.”,"\</div\>\<div class=‘widthframe’\>",“3.”,"\</div\>\<div class=‘lengthframe’\>",$choc);

[//1.17mm](https://1.17mm) 2.53mm 3.140mm

//echo str\_replace(“world”,“Peter”,“Hello world!”);

?\>

As you can see I am trying to say anything after “1.” or “2.” or “3.” end a div and replace with a div.
