View Single Post
  #5  
Old 01-16-2014, 08:54 PM
BlueMelon BlueMelon is offline
asdfg
BlueMelon's Avatar
Join Date: Sep 2008
Posts: 1,481
BlueMelon is a splendid one to beholdBlueMelon is a splendid one to beholdBlueMelon is a splendid one to beholdBlueMelon is a splendid one to behold
Since we are dealing with numbers, I would approach it differently with some simple math.

PHP Code:
function numberToArray(temp.n) {
  
temp.abs(temp.n);
  
temp.digits = {};
  while(
temp.!= 0) {
    
temp.digits.insert(0temp.10);
    
temp.int(temp.n/10);
  }
  return 
temp.digits;
}

function 
onCreated() {
  
temp.fullnumber 482;

  
temp.digits numberToArray(temp.fullnumber);
  echo(
temp.digits[0]); // 4
  
echo(temp.digits[1]); // 8
  
echo(temp.digits[3]); // 2

If you want it the other way (reversed), change the .insert(0, ...) with .add(...)
__________________
http://i.imgur.com/OOJbW.jpg
Reply With Quote