crashmaster Posted May 12, 2008 Share Posted May 12, 2008 Can anybody "translate" this into PHP ?? function toEntity() { var aa = document.form.utf.value; var bb = ''; for(i=0; i<aa.length; i++) { if(aa.charCodeAt(i)>127) { bb += '&#' + aa.charCodeAt(i) + ';'; } else { bb += aa.charAt(i); } } document.form.entity.value = bb; } Thx Link to comment https://forums.phpfreaks.com/topic/105275-js-php/ Share on other sites More sharing options...
soycharliente Posted May 12, 2008 Share Posted May 12, 2008 What does that code do? Link to comment https://forums.phpfreaks.com/topic/105275-js-php/#findComment-539080 Share on other sites More sharing options...
crashmaster Posted May 12, 2008 Author Share Posted May 12, 2008 it convert special chars into entities.. for example: á => ÿ Link to comment https://forums.phpfreaks.com/topic/105275-js-php/#findComment-539093 Share on other sites More sharing options...
soycharliente Posted May 12, 2008 Share Posted May 12, 2008 http://us2.php.net/htmlspecialchars Link to comment https://forums.phpfreaks.com/topic/105275-js-php/#findComment-539105 Share on other sites More sharing options...
rarebit Posted May 12, 2008 Share Posted May 12, 2008 i've also answered this in the js forum... Link to comment https://forums.phpfreaks.com/topic/105275-js-php/#findComment-539149 Share on other sites More sharing options...
NorthWestSimulations Posted May 12, 2008 Share Posted May 12, 2008 function toEntity() { var aa = document.form.utf.value; var bb = ''; for(i=0; i<aa.length; i++) { if(aa.charCodeAt(i)>127) { bb += '&#' + aa.charCodeAt(i) + ';'; } else { bb += aa.charAt(i); } } document.form.entity.value = bb; } <?php function toEntity(){ $aa = $_POST['frmval']; $bb = ''; do while ($i <= $aa){ $i++; } } // Not really sure what ur tryingb to do. Javascript is OOP while Php is primarily not. You will have to assign var's for length and stuff. ?> Link to comment https://forums.phpfreaks.com/topic/105275-js-php/#findComment-539221 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.