Jump to content

[SOLVED] str_replace


emexinc

Recommended Posts

...this is my problem...

 

<?php 
$size = "2 3/16 x 4 1/2";
$size = str_replace("x", "&#34;&#32;x", "$size");
echo $size."&#34;";
?>

 

or

 

<?php

$size = "2 3/16 x 4 1/2";

$size = str_replace("x", "&#34;&#32;x", "$size");

echo $size."&#34;";

?>

 

...and this echoes 2 3/16 " x 4 1/2"...but i am trying to get 2 3/16" x 4 1/2"...i have tried this code below...

 

<?php 
$size = "2 3/16 x 4 1/2";
$size = str_replace("&#32;x", "&#34;&#32;x", "$size");
echo $size."&#34;";
?>

 

or

 

<?php

$size = "2 3/16 x 4 1/2";

$size = str_replace("&#32;x", "&#34;&#32;x", "$size");

echo $size."&#34;";

?>

 

...and this echoes 2 3/16 x 4 1/2"...but i am assuming that it didn't find anything to replace...

 

...but then it can't find the x with a space in front of it...the challenging part of this code is the dimensions are changing ( 4" - 4 1/2" - 4 1/16" )...that's why i am looking for an x...and trying to add the quote, and then easily adding a quote at the end...how do i go about getting this work, and possibly getting this to work easier than i have it set up?...thanks

 

...sorry, i have the code posted twice to show that the code function in this forum is changing &#34; to &#38;#34;

Link to comment
https://forums.phpfreaks.com/topic/139439-solved-str_replace/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.