View Single Post
  #10  
Old 02-16-2007, 02:06 AM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
Some string functions I use sometimes.

ReverseArray:
PHP Code:
public function reversearray(temp.array) {
  
temp.newarray;
  
temp.i;
  
  
newarray = "";
  for (
i = array.size() - 1; i > -1; i --) {
    
newarray.add(array[i]);
  }
  return 
newarray;
} 
ReverseString:
PHP Code:
public function reversestring(temp.string) {
  
temp.i;
  
temp.out;
  
  for (
i = string.length() - 1; i > -1; i --) {
    
out @= string.charat(i);
  }
  return 
out; 
} 
ReplaceSubString:
PHP Code:
public function replacesubstring(temp.string, temp.position, temp.length, temp.newstring) {
  
temp.stringa;
  
temp.stringb;
  
temp.outstring;
  
  if (
position < 0) {
    return;
  }
  
stringa = string.substring(0, position);
  
stringb = string.substring(position + length, -1);
  
outstring = stringa @ newstring @ stringb;
  return 
outstring;
} 
__________________
Reply With Quote