Replacement string that comes from database

Hi i have a query that retrives fields from the database now i have a query now on the form teh user has to put sign (£) i am trying to grab that row and evrytime it finds the (£) on that particular field replace when it echo the row film_price replace any (£) signs with (&pound)

Example on the databse the user typed £45 to £55 when echo that row on html replace the (£) signs with html (£) which is (&pound) i have tried

but didnt echo the row what i am doing wrong?

<?php
  $vOriginalString = $film_price;
  $vSomeSpecialChars = array("£", "$");
  $vReplacementChars = array("&pound POA", "&pound POA");
  $vReplacedString = str_replace($vOriginalString);

  echo $vReplacedString;
?>

Or simply switch to UTF-8 and keep the pound as is :slight_smile:
Let’s call a spade a spade; ISO-8859-* sucks (not as much as the proprietary CP-* crap though).
(yeah, I don’t like character sets, does it show? (:slight_smile:

Thanks for the help this way did the job

<meta content="text/html; charset=iso-8859-15" http-equiv="Content-Type">
<?php
$userInputEntities = htmlentities($viewing_price);

//Now we can display it
echo $viewing_price;
?>

Your code won’t work because your only supplying the str_replace() function with one argument when it requires three, see the updated code below which should work fine.

<?php

  $vOriginalString = $film_price;
  $vSomeSpecialChars = array("£", "$");
  $vReplacementChars = "&pound; POA";
  $vReplacedString = str_replace($vSomeSpecialChars, $vReplacementChars, $vOriginalString);

  echo $vReplacedString;

?>

Also as a note, when using special character codes such as “pound” you always need to end it with a semicolon “;” otherwise the browser will skip over it and read it as plain text.