Advertisement
Guest User

Untitled

a guest
Sep 25th, 2011
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.51 KB | None | 0 0
  1. function strToHex( $string )
  2. {
  3.     $hex='';
  4.    
  5.     for ( $i=0; $i < strlen( $string ); $i++ )
  6.     {
  7.         $hex .= dechex( ord( $string[$i] ) );
  8.     }
  9.    
  10.     return $hex;
  11. }
  12.    
  13. function endian_swap_uint( &$x )
  14. {
  15.     $x = ( $x>>24 ) |
  16.         ( ( $x << 8 ) & 0x00FF0000 ) |
  17.         ( ( $x >> 8 ) & 0x0000FF00 ) |
  18.         ( $x << 24 );
  19. }
  20.  
  21. endian_swap_uint( strToHex( fread( $filePointer, 4 ) ) );
  22.  
  23. /*
  24.  
  25. strToHex() - returns the wrong endianess but in a string.
  26. endian_swap_uint() - tries to straighten it out, but is just returning a NULL
  27.  
  28. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement