|  | Posted by Kimmo Laine on 06/13/76 11:51 
"McHenry" <mchenry@mchenry.com> wrote in message news:44a377a2$0$12236$5a62ac22@per-qv1-newsreader-01.iinet.net.au...
 >
 > "IchBin" <weconsul@ptd.net> wrote in message
 > news:iMKcnZphKs4J6T7ZUSdV9g@ptd.net...
 >> McHenry wrote:
 >>> "Ruben van Engelenburg" <ruben@NOSPAM.nl> wrote in message
 >>> news:44a28738$0$31643$e4fe514c@news.xs4all.nl...
 >>>> McHenry wrote:
 >>>>> For example the following is retrieved as a price however it would be
 >>>>> easier to extract using a regex if the code was first converted to a
 >>>>> dollar sign:
 >>>>>
 >>>>> <h3>
 >>>>>
 >>>>>  $249,000
 >>>>>
 >>>>> </h3>
 >>>>
 >>>> Hi McHenry,
 >>>>
 >>>> You're probably looking for html_entity_decode():
 >>>>
 >>>> <?php
 >>>> echo html_entity_decode('<h3>$249,000</h3>');
 >>>> ?>
 >>>>
 >>>> HTH.
 >>>> Ruben.
 >>>>
 >>>> --
 >>>> http://www.phpforums.nl
 >>>
 >>> When I run the example code above it outputs the HTML as it appears
 >>> above and doesn't convert the ascii codes ?
 >>
 >> when I run it I get $249,000
 >
 > Output displayed in the browser ? Maybe the browser is converting the
 > ASCII however it is still being fed the raw codes by PHP
 >
 > If you output the function to a txt file you'll find it's still the raw
 > codes...
 >
 
 Read The Fine Manual :)
 
 http://php.net/html-entity-decode
 
 On that page, there's an example code:
 function unhtmlentities($string)
 {
 // replace numeric entities
 $string = preg_replace('~&#x([0-9a-f]+);~ei', 'chr(hexdec("\\1"))',
 $string);
 $string = preg_replace('~&#([0-9]+);~e', 'chr(\\1)', $string);
 // replace literal entities
 $trans_tbl = get_html_translation_table(HTML_ENTITIES);
 $trans_tbl = array_flip($trans_tbl);
 return strtr($string, $trans_tbl);
 }
 
 Try and see if it works.
 
 --
 "ohjelmoija on organismi joka muuttaa kofeiinia koodiksi" -lpk
 spam@outolempi.net | Gedoon-S @ IRCnet | rot13(xvzzb@bhgbyrzcv.arg)
  Navigation: [Reply to this message] |