aioseop_convert_bytestring

The All In One SEO Pack aioseop convert bytestring function.

Description

(int) aioseop_convert_bytestring( $byte_string ); 

Returns (int)

Parameters (1)

0. $byte_string
The byte string.

Usage

  1. if ( !function_exists( 'aioseop_convert_bytestring' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'all-in-one-seo-pack/all_in_one_seo_pack.php'; 
  3.  
  4. // The byte string. 
  5. $byte_string = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = aioseop_convert_bytestring($byte_string); 
  9.  

Defined (1)

The function is defined in the following location(s).

/all_in_one_seo_pack.php  
  1. function aioseop_convert_bytestring( $byte_string ) { 
  2. $num = 0; 
  3. preg_match( '/^\s*([0-9.]+)\s*([KMGTPE])B?\s*$/i', $byte_string, $matches ); 
  4. if ( ! empty( $matches ) ) { 
  5. $num = (float) $matches[1]; 
  6. switch ( strtoupper( $matches[2] ) ) { 
  7. case 'E': 
  8. $num *= 1024; 
  9. case 'P': 
  10. $num *= 1024; 
  11. case 'T': 
  12. $num *= 1024; 
  13. case 'G': 
  14. $num *= 1024; 
  15. case 'M': 
  16. $num *= 1024; 
  17. case 'K': 
  18. $num *= 1024; 
  19.  
  20. return intval( $num );