* Thus wrote Pablo Gosse:
>       
>       if ($mode == 1) {
>               $html = htmlentities($html, ENT_QUOTES);
>       } else {
>               $trans_tbl = get_html_translation_table(HTML_ENTITIES,
> ENT_QUOTES);
>               $trans_tbl = array_flip($trans_tbl);
>               $html = strtr($html, $trans_tbl);
>       }
>       return $html;
> }
> 
> ...
> 
> Can anyone give me an idea as to why single quotes are not being
> translated here?

If you look at $trans_tbl["'"] You'll see that it equals '
instead of '.

> 
> I've fixed the problem simply by adding a str_replace() call to replace
> all instances of ' with ' before returning the $html variable in
> the decode function, but I really want to know why it's not working
> properly.

Two other ways:

  - Set $trans_tbl["'"] =  '''; before you flip the arrray.

  or 

  - use the translation table instead of htmlentities:
  

  $trans_tbl = get_html_translation_table(HTML_ENTITIES, ENT_QUOTES);
  if ($mode != 1) {
    $trans_tbl = array_flip($trans_tbl);
        }
  $html = strtr($html, $trans_tbl);


Curt
-- 
First, let me assure you that this is not one of those shady pyramid schemes
you've been hearing about.  No, sir.  Our model is the trapezoid!

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to