note 97891 added to function.htmlentities

From: Date: Fri, 14 May 2010 00:22:51 +0000
Subject: note 97891 added to function.htmlentities
Groups: php.notes 
Request: Send a blank email to php-notes+get-169229@lists.php.net to get a copy of this message
I needed a simple little function to take a string and convert extended ascii characters into html entities. I couldn't find a function for this so I whipped one up. <?php /* Convert Extended ASCII Characters to HTML Entities */ function ascii2entities($string){ for($i=128;$i<=255;$i++){ $entity = htmlentities(chr($i), ENT_QUOTES, 'cp1252'); $temp = substr($entity, 0, 1); $temp .= substr($entity, -1, 1); if ($temp != '&;'){ $string = str_replace(chr($i), '', $string); } else{ $string = str_replace(chr($i), $entity, $string); } } return $string; } echo ascii2entities("•"); ?> ---- Server IP: 69.147.83.197 Probable Submitter: 207.212.173.2 ---- Manual Page -- http://www.php.net/manual/en/function.htmlentities.php Edit -- https://master.php.net/note/edit/97891 Del: integrated -- https://master.php.net/note/delete/97891/integrated Del: useless -- https://master.php.net/note/delete/97891/useless Del: bad code -- https://master.php.net/note/delete/97891/bad+code Del: spam -- https://master.php.net/note/delete/97891/spam Del: non-english -- https://master.php.net/note/delete/97891/non-english Del: in docs -- https://master.php.net/note/delete/97891/in+docs Del: other reasons-- https://master.php.net/note/delete/97891 Reject -- https://master.php.net/note/reject/97891 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#169229) next »