Results 1 to 2 of 2

Thread: £ in a variable

  1. #1
    Join Date
    Sep 2007
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default £ in a variable

    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
    PHP 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
    PHP Code:
     $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

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    You're using the wrong character encoding. Switch to UTF-8. Also, PHP by default doesn't like multi-byte encodings very much; make sure you're using the mbstring with function overloading turned on.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •