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 (
= array.size() - 1> -1--) {
    
newarray.add(array[i]);
  }
  return 
newarray;

ReverseString:
PHP Code:
public function reversestring(temp.string) {
  
temp.i;
  
temp.out;
  
  for (
string.length() - 1> -1--) {
    
out @= string.charat(i);
  }
  return 
out

ReplaceSubString:
PHP Code:
public function replacesubstring(temp.stringtemp.positiontemp.lengthtemp.newstring) {
  
temp.stringa;
  
temp.stringb;
  
temp.outstring;
  
  if (
position 0) {
    return;
  }
  
stringa string.substring(0position);
  
stringb string.substring(position length, -1);
  
outstring stringa newstring stringb;
  return 
outstring;

__________________
Reply With Quote