Jump to content


Photo

need help with stristr


  • Please log in to reply
No replies to this topic

#1 oracle259

oracle259
  • Members
  • PipPipPip
  • Advanced Member
  • 119 posts

Posted 29 September 2006 - 03:06 AM

How can i improve on the following code


while ($res = @mysql_fetch_array($result)) {
 if (stristr(trim($user, $reserved)) {
   $length = strlen($reserved);
     for ($k = 1; $k  <= $length; $k++) {
      $percent = "%";
}

$newuser = eregi_replace($reserved, $percent, trim($user));
$percent = " ";

    }
 }

echo $newuser;


The problem is this, say $user = "bob.camsara and $reserved names are bob and sara the output would be %%%.camsara.

Question how can i modify the code to go through the entire result to get %%%.cam%%%%.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users