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;
}