Jump to content

£ in a variable


coops

Recommended Posts

HI,

I'm doing a simple function retrieve data and export the data into xml, but found out xml does not like all character.  The character I have found are '&','','<','>','£'.  So I have developed a simple function that will replace curtain character within a string with the HTML code that XML likes. '&#38;','&#172;','&#60;','&#62;','&#163;'

It seems to work with all character, but apart from "£" sign.  The only reason is because if i use the below code

 

while($i < strlen($value)){     

      $ia=0;

        $sign = $value{$i};

           

      while($ia < count($strarValidation)){

       

        if($strarValidation[$ia] == $sign){               

         

          $sign = $strarNewChar[$ia];

          break;

        }

        $ia++;

      }

     

      $endValue.= $sign;   

The value at $sign = $value{$i}; for a £ is the HTML code, not "£".  So the function can't be used...

 

Does anyone else know of a way that I can stop the "£" converting to the html code when converting the string variable into a array?

 

Thanks

 

Link to comment
Share on other sites

The code I'm using for the form is

  <form onsubmit="return check(this)" action="store.php" method="post" name="fromMain" target="_self" id="fromMain">

 

<input name="txtCustomerName" type="text" id="0">

 

and within store.php, I'm using a $_POST to retrieve the string

 

Link to comment
Share on other sites

This will give a value of

The £ sign comes from the form tho and then it goes into the original function (stated at the beginning), but Don't know why its converting the £ to a HTML code when changing the variable to a array..

 

But if it goes straight to an string and not using the form ITS ALL OK

$value = "£" ;

 

echo "Size ".strlen($value);

       

  while($i < strlen($value)){     

      $ia=0;

        echo "<br>".$value{$i};

$++;

}

 

This will show the correct data

 

Link to comment
Share on other sites

Sadly I need the pound Sing as the function goes through a string to look for character that affecting XML and converts it into the HTML code and then inputs the new string into XML. 

 

The data comes from a form, using $_POST

 

so $value = $_POST...

 

then the $Value is converted to an array $value{}... 

Then it loops around looking for the characters that will affect XML and replace them...

 

But using $_POST already converts £ and ' ... but does not convert any other character that will affect XML.......

 

 

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.