Skip to content

Instantly share code, notes, and snippets.

@scribu
Created October 23, 2010 16:04
Show Gist options
  • Save scribu/642361 to your computer and use it in GitHub Desktop.
Save scribu/642361 to your computer and use it in GitHub Desktop.
get_ascii_array()
<?php
/**
* Returns an array containing the ASCII codes of a string (useful for decomposition)
* Example: print_r(get_ascii_array('ș'))
*
* @param string $str
* @return array
*/
function get_ascii_array($str) {
$r = array();
$length = strlen($str);
for ($i=0; $i < $length; $i++) {
$r[] = ord($str[$i]);
}
return $r;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment