note 80185 deleted from function.bin2hex by danbrown

From: 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 = "&amp;";}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: &#67&#114&#97&#122&#121&#80&#114&#111&#103 &#114&#97&#109&#109&#101&#114&#32&#116&#101 &#115&#116&#105&#110&#103&#32&#65&#83&#67 &#73&#32&#50&#32&#65&#78&#83&#73&#32&#99 &#111&#110&#118&#101&#114&#115&#105&#111&#110 */ ASCIItoANSI ("PHP Power! => ",1); /* show: &#80&#72&#80&#32&#80&#111&#119&#101 &#114&#33&#32&#61&#62&#32 but really output is: &amp;#80&amp;#72&amp; #80&amp;#32&amp;#80&amp;#111&amp;#119 &amp;#101&amp;#114&amp;#33&amp;#32&amp; #61&amp;#62&amp;#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>

« previous php.notes (#163115) next »