/    Sign up×
Community /Pin to ProfileBookmark

can php transform text to html entity numbers?

hi all,

i was wondering if there is a way to let php translate a plain text into their html entity NUMBER instead of entity NAME, like the htmlentities() function does.
This is because i want to import the transformed text into flash, and flash doesn’t understand entity names, it needs entity numbers.

thanks for the help!

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@NightShift58Jan 15.2007 — See: http://us2.php.net/manual/en/function.htmlentities.php#71324

(Read the last and next to last entries)
Copy linkTweet thisAlerts:
@bokehJan 15.2007 — Do you mean like this?[code=php]<?php

$string = 'abcde fghij';
$out = '';
foreach(str_split($string) as $char) #PHP 5 only
{
$out .= '&#'.ord($char).';';
}
echo $out;

?>[/code]
Copy linkTweet thisAlerts:
@NightShift58Jan 15.2007 — A PHP string - as in some other languages - is an array of characters. If you don't have PHP5, you can still access the string as an array. Using Bokeh's logic, here's an example:[code=php]<?php
$string = 'abcde fghij';
$out = '';
for ($x=0; $x < strlen($string); $x++) {
$out .= '&#' . ord($string[$x]) . ';';
}
echo $out;
?>[/code]
Copy linkTweet thisAlerts:
@m_i_c_authorJan 15.2007 — waauw, thanks for all the help!

This should do the trick ?
×

Success!

Help @m_i_c_ spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...