note 80185 deleted from function.bin2hex by danbrown
| From: | danbrown@php.net | Date: | Thu, 19 Nov 2009 21:59:07 +0000 |
| Subject: | note 80185 deleted from function.bin2hex by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-163115@lists.php.net to get a copy of this message | ||
Note Submitter: codeguru at crazyprogrammer dot cba dot pl
----
<?php
function ASCIItoANSI($text2encode,$m=Null){
if ($m<>0){$mode = "&";}else{$mode = chr(38);}
// starting loop incl. lenght of base string
for ($i=0;$i<=strlen($text2encode)-1;++$i)
{
// add first & char # char + converted 2 ANSI codes
$ANSI .= $mode.chr(35).hexdec(bin2hex($text2encode[$i]));
}
echo $ANSI; // Here`s Really string contains ANSI codes
}
// **************** U S A G E ********************//
// ASCIItoANSI (String or $SomeVar);
// ^^^^^ returns converted 2 ANSI
// ^^^ [ Can be used on WWW ]
// ASCIItoANSI (String or $SomeVar,1);
// ^^^^^^ returns converted 2 ANSI in View mode
// ^^^ [ Can`t be used on WWW ]
//++++++++++++++ E X A M P L E S ++++++++++++++++//
// FIRST SAMPLE:Sample Conversion
//
ASCIItoANSI ("PHP Power! => ");
/*
show: PHP Power! =>
but
really output is:
CrazyProg
rammer te
sting ASC
I 2 ANSI c
onversion
*/
ASCIItoANSI ("PHP Power! => ",1);
/*
show: PHP Powe
r! => 
but
really output is: &#80&#72&
#80&#32&#80&#111&#119
&#101&#114&#33&#32&
#61&#62&#32
*/
?>
<br><br>
<!-- MAIL PROTECT EXAMPLE (BASIC)-->
1 Sample
<a href="
<? ASCIItoANSI(
"mailto:codeguru@crazyprogrammer.cba.pl");?>"
>Mail me</a>
<!-- MAIL PROTECT EXAMPLE (ADVANCE)-->
2 Sample
<a href="
<? ASCIItoANSI(
"mailto:codeguru@crazyprogrammer.cba.pl?subject=php&body=question"
);?>"
><? ASCIItoANSI(
"codeguru@crazyprogrammer.cba.pl"
);?></a>