Skip to content

Instantly share code, notes, and snippets.

@rbarros
Created March 30, 2012 00:31
Show Gist options
  • Save rbarros/2245298 to your computer and use it in GitHub Desktop.
Save rbarros/2245298 to your computer and use it in GitHub Desktop.
String2Int
<?php
$data = "abc def ";
echo $strlen = strlen( $data );
echo "<br/>";
echo $c = $strlen/3;
echo "<br/>";
echo $w = ceil( $c );
echo "<br/>";
echo $h = ceil( sqrt( $w /3 ) );
echo "<br/>";
$i=0;
for($x=0; $x<$w; $x++){
for($y=0; $y<$h; $y++){
echo "[ ".$x.":".$y."( ".ord($data{$i}).",".ord($data{$i+1}).",".ord($data{$i+2})." ) ]";
echo $y==$h?"<br/>":"";
$i+=3;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment