Converting hex into a text or normal string

This item was filled under [ Code Snippet, PHP ]

Converting hex into a text or normal string using PHP code.
Fungsi mengkonvert dari tulisan bentuk hex kedalam normal string menggunakan PHP.

<?php
function hex2text($hexstr) {
 $hex = explode('%',$hexstr);
 array_shift($hex);
    $str = '';
    foreach($hex as $hexcode) {
     $str .= chr(base_convert($hexcode, 16, 10));
    }
    return $str; 
}
?>

contoh penggunaan:

echo hex2text("%40"); // <-- akan menampilkan @
echo "<br />";
echo hex2text("%2A"); // <-- akan menampilkan *
echo "<br />";
echo hex2text("%40%2A"); // <-- akan menampilkan @*

semoga mambantu :mrgreen:

Rate this topic:
1 Star2 Stars3 Stars4 Stars5 Stars (2 votes, average: 5 out of 5)
Loading ... Loading ...
Popularity: 1,327 views
Tagged with: [ , ]
You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

Artikel Sejenis

3 Comments on “Converting hex into a text or normal string”

  • pak_dhe
    3 August, 2009, 17:11

    gag bisa mas ??
    udah ta’ simpan di file PHP !!

    Like or Dislike: Thumb up 0 Thumb down 0
  • 14 August, 2009, 18:45

    Terimkasih atas komentarnya, kami update artikel berikut contoh penggunaannya.
    ini contoh kasus penggunaannya:

    echo hex2text("%40"); // <-- akan menampilkan @
    echo "<br />";
    echo hex2text("%2A"); // <-- akan menampilkan *
    Like or Dislike: Thumb up 0 Thumb down 0
  • dsdasd
    1 September, 2010, 14:19

    #164C4

    Like or Dislike: Thumb up 0 Thumb down 0

Leave a Comment

Halaman ini di eksekusi dalam waktu 12.176 detik! (waaaaaaaaaaa mulai lambat neehh...)