ez
New Member
Posts: 46
|
Post by ez on Jan 24, 2004 12:34:03 GMT -5
I really do not know what catagory I should put this thread and ask help from someone who knows PHP function.
1. A function which takes a string as a parameter and replaces all entries of one symbol with another. The function will look something like:
function replacechars(string, char1, char2);
i.e. if we give it three input parameters: "Welcome" letter "o", "O" It will return the string: "WelcOme"
2. Another function returns "1" in case if a substring found in a string, otherwise "0" returned. Ideally the function will return a number of entries.
function scanstring(string, substring);
I am not sure if predifined functions already exist.
Thanks in advance.
|
|
|
Post by Armstrong on Jan 24, 2004 15:56:31 GMT -5
1: $strNew = str_replace("o", "O", "Welcome");
2: since you want 1 or 0 you can do this:
function scanstring($strexp, $substring) { return (strstr($strexp, $substring)==$substring?1:0); }
for the first one it's a little complicated, you have to loop the string.
|
|
ez
New Member
Posts: 46
|
Post by ez on Jan 24, 2004 16:29:03 GMT -5
JJ.. That works Great ;D Thanks alot ez
|
|