Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8628893
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T08:40:04+00:00 2026-06-12T08:40:04+00:00

I am having a problem trying to understand functions with variables. Here is my

  • 0

I am having a problem trying to understand functions with variables. Here is my code. I am trying to create friendly urls for a site that reports scams. I created a DB full of bad words to remove from the url if it is preset. If the name in the url contains a link I would like it to look like this: example.com-scam.php or html (whichever is better). However, right now it strips the (.) and it looks like this examplecom. How can I fix this to leave the (.) and add a -scam.php or -scam.html to the end?

functions/seourls.php

/* takes the input, scrubs bad characters */
function generate_seo_link($link, $replace = '-', $remove_words = true, $words_array = array()) {
  //make it lowercase, remove punctuation, remove multiple/leading/ending spaces
  $return = trim(ereg_replace(' +', ' ', preg_replace('/[^a-zA-Z0-9\s]/', '', strtolower($link))));

  //remove words, if not helpful to seo
  //i like my defaults list in remove_words(), so I wont pass that array
  if($remove_words) { $return = remove_words($return, $replace, $words_array); }

  //convert the spaces to whatever the user wants
  //usually a dash or underscore..
  //...then return the value.
  return str_replace(' ', $replace, $return);
}

/* takes an input, scrubs unnecessary words */
function remove_words($link,$replace,$words_array = array(),$unique_words = true)
{
  //separate all words based on spaces
  $input_array = explode(' ',$link);

  //create the return array
  $return = array();

  //loops through words, remove bad words, keep good ones
  foreach($input_array as $word)
  {
    //if it's a word we should add...
    if(!in_array($word,$words_array) && ($unique_words ? !in_array($word,$return) : true))
    {
      $return[] = $word;
    }
  }

  //return good words separated by dashes
  return implode($replace,$return);
}

This is my test.php file:

require_once "dbConnection.php"; 


$query = "select * from bad_words";
$result = mysql_query($query);


while ($record = mysql_fetch_assoc($result)) 
{
    $words_array[] = $record['word'];
}



$sql = "SELECT * FROM reported_scams WHERE id=".$_GET['id'];
$rs_result = mysql_query($sql);

while ($row = mysql_fetch_array($rs_result)) {

$link = $row['business'];

}


require_once "functions/seourls.php";
echo generate_seo_link($link, '-', true, $words_array);

Any help understanding this would be greatly appreciated 🙂 Also, why am I having to echo the function?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T08:40:05+00:00Added an answer on June 12, 2026 at 8:40 am

    Your first real line of code has the comment:

    //make it lowercase, remove punctuation, remove multiple/leading/ending spaces
    

    Periods are punctuation, so they’re being removed. Add . to the accepted character set if you want to make an exception.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having a problem trying to create a Javascript function that checks all the
I am having problem that when i am trying to submit the form by
I'm having a pretty big problem trying to create navigation on my page. If
I am having a problem trying to use the prependTo() function in jQuery... for
I'm having a problem trying to format the output on the jQuery UI datepicker.
I'm having a problem trying to make eclipse and aspectj work for Dynamic Web
I'm having a problem when trying to pass an array back to a COM
I have been having this annoying problem when trying to implement a picture gallery
I'm having a problem with a WCF service trying to consume it from Java.
I'm having a problem whereby I am trying to load some html onto a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.