Jump to content


Exploding and Mysql arrays

  • Please log in to reply
2 replies to this topic

#1 oracle259

  • Members
  • PipPipPip
  • Advanced Member
  • 119 posts

Posted 23 September 2006 - 04:11 AM

Not certain which forum this belongs in but here goes.

How can I explode numbers and symbols from a mysql query.
eg.  if  i have a table with column pwd which contains  2 row with the following information:

??? how do i go about exploding the numbers and symbols to get a result that gives me the following output:


If you have any suggestions i would really appreciate it

#2 akitchin

  • Staff Alumni
  • Advanced Member
  • 2,516 posts
  • LocationCalgary, AB, Canada

Posted 23 September 2006 - 05:06 AM

first of all, you're not looking for exploding.  exploding breaks up a string into an array based on what you're exploding with; that is, you're splitting up the string based on a delimiter.

second, a simple str_replace() should work for your purposes.  load all of your unwanted characters into an array and replace them with nothing:

$unwanted_characters = array

$replacees = array_merge(range(0, 9), $unwanted_characters);

$actual_password = str_replace($replacees, '', $stored_password);

this will automatically include digits, so just add all the other characters you want to get rid of into that $unwanted_characters array.  look up the function, it's useful.

#3 oracle259

  • Members
  • PipPipPip
  • Advanced Member
  • 119 posts

Posted 23 September 2006 - 05:45 AM

Ok i read up on str_replace and ur right its exactly what i was looking for. But im still somewhat confused so let me tell u what im tryin to do. Basically, i need a function that would check a userid for profanity eg fshit.%4m would not be accepted as a proper userid. The banned words would be stored in a mysql database and userids would be checked against it. Ok now need to know if im on the right track with the following code:

$sql = "SEARCH profanity FROM filter";
$result = @mysql_query($sql);
while ($words = @mysql_fetch_array($result, MYSQL_BOTH) {
$profanity[] = $words[profanity];
$kill_characters = array ('.', '-', '_');
$kill_num = range(0,9);
$kill_all = array_merge($kill_num, $kill_characters);

$userid = str_replace($kill_all, '' ", $userid);

$obscene = $profanity[];
foreach ($obscene as $obscenities) {
if (stristr(trim($userid), $obscenities)) {
  $match = similar_text($userid, $obscenities, $percent);
  $percent = round($percent, 2);
  if ($percent >= '50') {
  echo "Sorry, username <b>$userid</b> is too vulgar. Please select another username.";
} else {
echo "Congratulations, username <b>$userid</b> is available.";
} else {
echo "Congratulations, username <b>$userid</b> is available.";


Where am i going wrong?  ???

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users